adding fields together

toddbingham

Registered User.
Local time
Today, 01:31
Joined
Jul 8, 2003
Messages
93
Have a form with to text box feilds, option1 and option2. When values are manually entered into them, want it to add then together and place to total amount into a total field the is part of table1.
How do I do that?
 
It isn't necessary to store the calculated value nor is it good practice. The easiest solution is to calculate the sum in the form's query.

Select fldA, fldB, fldC, Nz(fldB, 0) + Nz(fldC, 0) As BCTot
From YourTable;

Then bind your form to BCTot. Whenever someone changes the value of fldB or fldC, the value of BCTot will change AUTOMATICALLY!! No code is required.
 
Okay, I'm fairly new to the forum and Access, but I had a similar problem recently. Mine involved criteria where if an order quantity was reached then discounts were applied. i found this easier to build as a calculated control on the form using VBA. I guess it depends on your knowledge of VBA or SQL.

Cheers, Lol :D
 
I agree that not all calculations can be done in a query. However the query should be your first choice whether you know VBA or not. The reason that I suggest using SQL is actually twofold.
1. The result is populated as soon as one of the base fields is modified. If you calculate on the form, you need code in the AfterUpdate event of each base field to cause the calculated field to be recalculated.
2. If your calculated field will be displayed in a continuous form, you will find that all the rows show the same value if you do the calculation in the form whereas if you do the calculation in the query you will see correct values for each row.
 
Thats where i put mine, in the AfterUpdate part. Works great. However, I must say I'm more exzperienced with VB than Access, that's why I chose this route.

Lol
 

Users who are viewing this thread

Back
Top Bottom