473,387 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to add several fields in a form

135 100+
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
2 1151
Stwange
126 Expert 100+
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
Gilberto
135 100+
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

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

Similar topics

17
by: wolfing1 | last post by:
Like, I know if several checkboxes have the same name, I can get the ones that were checked after submit with a request.form("name") and maybe do a split(request.form("name"),",") to cycle through...
1
by: jbroome | last post by:
I have several tables that contain the same information as Identifying records but then with additional info that differs from table to table. e.g. 1 database of school students with their...
2
by: L Mehl | last post by:
Hello -- A form adds records for an account and an entry date pre-selected by the user. I use the Load event to get those 2 fields to appear in the form when it is first displayed. Problem...
1
by: Coy Howe | last post by:
What is the best way to enter a new record and have a common ID # or Social Security #, for example, populate several tables at the same time? I have a main table with an auto number and a dozen...
2
by: Tim Pollard | last post by:
Hi I'm hoping someone can help me with an access problem I just can't get my head around. I normally use access as a back end for asp pages, just to hold data in tables, so queries within access...
3
by: Yossi | last post by:
Several User-Controls are included in my .aspx file. In addition, one Submit button is used to post all the .aspx file data. I would like to manage the fields of a specific User-Control within the...
5
by: Matthias Nagl | last post by:
Hello List! I would like to combine the contents of several rows of a subquery. After several hours of search in the documentation and the internet I didn'T find a solution and hope anyone can...
8
by: TORQUE | last post by:
Hi, I am having some trouble with recording a field on a form into my Table after formatting it to calculate several fields on the form. If i just put the amount in the field and have it linked...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
2
by: farouqdin | last post by:
Hi all i have code which loops through table and deletes the duplicate records. This code does it for one table. How do i change it so it goes through several tables? On Error Resume Next Dim...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.