|
-
Feb 25th, 2006, 07:05 AM
#1
Thread Starter
Lively Member
[RESOLVED] Urgent And Important!
Just 2 days left to complete the application! 
I have a table in database called accountholder and fields in that table known as
intamount(means Intial Amount) and accbalance(Account Balance)
I have a form in visual basic to create a new account, In that field there is intial account field, now the thing that i want to do is :-
When an account is created, The initial amount entered into the database updates the account balance when the acount is created, so is there any code that updates the new account accbalance only and not all the records accbalance in the table.
I'm not getting the sql statement.Please anybody!
Regards,
Muhammad Haris
-
Feb 25th, 2006, 07:12 AM
#2
Re: Urgent And Important!
You would do an UPDATE tablename SET fieldname = whatever WHERE fieldname = whatever
Without knowing your exact table and field structure I can't me more specific than that.
What do you have for an SQL statement now that you can't get working.
-
Feb 25th, 2006, 07:19 AM
#3
Thread Starter
Lively Member
Re: Urgent And Important!
I have
VB Code:
cn.Execute "UPDATE accountholder SET accountholder.accbalance = [intamount]+[accbalance];"
I can't get what to use for where clause as i want where to be accno of the newly created account!
I can get you a screenshot of the database if you want...
Last edited by Muhammad Haris; Feb 25th, 2006 at 07:23 AM.
-
Feb 25th, 2006, 08:26 AM
#4
Addicted Member
Re: Urgent And Important!
At the time of creating the account, why don't you INSERT instead of UPDATE.
INSERT INTO "your table name" (list of the fields in the table) VALUES
(list of the values)
OR
You can use assign values to the fields programmatically :
rs is the recordset variable containing refernce to your table
VB Code:
rs.fields("accno")= 'the value that should be contained by accno
rs.fields("acctype") = 'the value of acctype
and so on for all the fields.
The argument passed to rs.fields must exactly match the field name in the table definition.
-
Feb 25th, 2006, 08:42 AM
#5
Thread Starter
Lively Member
Re: Urgent And Important!
I am getting a logic i will try and see what happens but update command is too important for me as the deposits and withdrawal will need those things to be done.Anyone got correct sql syntax?
Anways , does anybody know how to show show sql statment result of adodc in a text file , for example
text1.text = adodc1.recordsource "select name from accountholder where accno = 9"
something like that
Last edited by Muhammad Haris; Feb 25th, 2006 at 08:47 AM.
-
Feb 25th, 2006, 08:43 AM
#6
Addicted Member
Re: Urgent And Important!
One more thing :
Before programmatically assigning values :" rs.Addnew"
After assigning the values : "rs.update "
-
Feb 25th, 2006, 08:51 AM
#7
Thread Starter
Lively Member
Re: Urgent And Important!
 Originally Posted by Muhammad Haris
I am getting a logic i will try and see what happens but update command is too important for me as the deposits and withdrawal will need those things to be done.Anyone got correct sql syntax?
Anways , does anybody know how to show show sql statment result of adodc in a text file , for example
text1.text = adodc1.recordsource "select name from accountholder where accno = 9"
something like that
Read my updated code!
-
Feb 25th, 2006, 09:56 AM
#8
Addicted Member
Re: Urgent And Important!
I don't see what you want?
If you want to see the values in the fields of the record source then you will have to draw a textbox for each field ,
set the datasource property to the adodc control and
datafield property to the field you want to display
-
Feb 25th, 2006, 10:02 AM
#9
Thread Starter
Lively Member
Re: Urgent And Important!
Yes, I want to do that but I want to display the details regarding the accno i enter in the account number text box for example
I enter account number 9 into accno.text and then in the accname.text it displays that account name that is in the accno 9 record.
Any Ideas or a piece of code ?
-
Feb 25th, 2006, 10:10 AM
#10
Addicted Member
Re: Urgent And Important!
how about this :
Place all the textboxes for displaying the fields of the table.
Have a separate textbox to enter the account number say txtaccno
Then :
adodc1.recordsource = "SELECT * FROM accountholder WHERE accno = " & trim$(txtaccno.text)
This will let you see all the fields of the record
-
Feb 25th, 2006, 10:12 AM
#11
Addicted Member
Re: Urgent And Important!
Since accno is autonumber field change trim$(txtaccno.text) to
val(trim$(txtaccno.text))
-
Feb 25th, 2006, 10:16 AM
#12
Addicted Member
Re: Urgent And Important!
One more thing after changing the recordsource you should call the refresh method of the adodc control
-
Feb 25th, 2006, 10:16 AM
#13
Thread Starter
Lively Member
Re: Urgent And Important!
are the other text boxes suppose to be connected to the adodc1 data fields?
-
Feb 25th, 2006, 10:19 AM
#14
Addicted Member
Re: Urgent And Important!
If you want to see just the name , then set the datasource and datafield property of the text box which is supposed to contain the name
If you don't want other fields then you can omit them
Last edited by srisa; Feb 25th, 2006 at 10:22 AM.
Reason: forgot something
-
Feb 25th, 2006, 10:23 AM
#15
Addicted Member
Re: Urgent And Important!
I am getting late , if you need anything more please hurry
-
Feb 25th, 2006, 10:30 AM
#16
Thread Starter
Lively Member
Re: Urgent And Important!
There can be several meanings of what you are saying, Just let me know in detail , I am including account title, account name and account balance and when i enter like 1 or 2(the account no) i want to display data of that id.
*I'm feeling like i'm the most newbiest person on the forum*
Regards,
Muhammad Haris
-
Feb 25th, 2006, 10:31 AM
#17
Thread Starter
Lively Member
Re: Urgent And Important!
Please can you tell me what does trim do ?
Regards,
Muhammad Haris
-
Feb 25th, 2006, 10:36 AM
#18
Addicted Member
Re: Urgent And Important!
trim removes the leading and trailing blank spaces.
For every field that you want to display you need to draw a text box and set the datasource and datafield properties.
Don't take offence. I have been working on the system for about 5 hours now and that is quite long for me
-
Feb 25th, 2006, 12:25 PM
#19
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|