By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,136 Members | 1,784 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,136 IT Pros & Developers. It's quick & easy.

how to add several fields in a form

100+
P: 135
Hello

I have a form with 3 textboxes where the user inputs numbers. Each box its bounded to its particular field in a table. I want to SUM the values of those 3 textboxes so that the total is stored in that same table.

Ive tried:

CODE

Me.L1.Value = [L1_Driver] + [L1_Passenger] + [L1_Rear]

but it doesnt return ANYTHING
Sep 7 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 126
Hello

I have a form with 3 textboxes where the user inputs numbers. Each box its bounded to its particular field in a table. I want to SUM the values of those 3 textboxes so that the total is stored in that same table.

Ive tried:

CODE

Me.L1.Value = [L1_Driver] + [L1_Passenger] + [L1_Rear]

but it doesnt return ANYTHING
I don't really have much experience with bounded text boxes, but try updating the field that L1 is bound to instead, and let it update the textbox itself.

Eg (assuming your table is called VEHICLE, the primary key is REG, which is stored in a textbox called txtReg, and L1 is bound to a field called TOTAL - alter the code accordingly)

Expand|Select|Wrap|Line Numbers
  1. dim total as Single
  2. total = CSng([L1_Driver]) + CSng([L1_Passenger]) + CSng([L1_Rear])
  3. DoCmd.RunSQL("UPDATE yourtablenamehere SET total = " & total & " WHERE REG = '" & txtReg.value & "';")
  4.  
If that doesn't work, try reopening the form and then see if it has updated. I'm sure someone here can tell you how to requery a bound form.

Hope this helps.
Sep 7 '07 #2

100+
P: 135
I don't really have much experience with bounded text boxes, but try updating the field that L1 is bound to instead, and let it update the textbox itself.

Eg (assuming your table is called VEHICLE, the primary key is REG, which is stored in a textbox called txtReg, and L1 is bound to a field called TOTAL - alter the code accordingly)

Expand|Select|Wrap|Line Numbers
  1. dim total as Single
  2. total = CSng([L1_Driver]) + CSng([L1_Passenger]) + CSng([L1_Rear])
  3. DoCmd.RunSQL("UPDATE yourtablenamehere SET total = " & total & " WHERE REG = '" & txtReg.value & "';")
  4.  
If that doesn't work, try reopening the form and then see if it has updated. I'm sure someone here can tell you how to requery a bound form.

Hope this helps.
Thanks i just tried:

Expand|Select|Wrap|Line Numbers
  1. Me.L1.Value = (Me.L1_Driver.Value + Me.L1_Passenger.Value + Me.L1_Rear.Value)
  2. Me.Refresh
  3.  
and it worked
Sep 7 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.