Adding to Fields (1 Viewer)

.Justin

Registered User.
Local time
Today, 06:32
Joined
Jun 29, 2009
Messages
38
I want to add two fields in my table.

One field is called Product Cost and the other is called Postage Fee. I then have a field called Total Cost. I want to be able to enter the Product cost and the Postage fee and the total to be added together in the Total Cost field.

How do I do this? I am rather confused :banghead:
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:32
Joined
Jul 2, 2005
Messages
13,826
The calculated field (TotalCost) should *only* exist in a query, not in the table.
 

.Justin

Registered User.
Local time
Today, 06:32
Joined
Jun 29, 2009
Messages
38
The calculated field (TotalCost) should *only* exist in a query, not in the table.

Okay so what would be the simplest way? What code do i put in the query? I also want it to add up on the form tho?
 

veraloopy

Registered User.
Local time
Today, 06:32
Joined
Apr 10, 2009
Messages
139
To update all your existing records, you would need to run an update query as RuralGuy mentioned.

Moving forwards, I would calculate this when entering the values on a form, probably in the After Update of the Postage Fee (or whichever of the 2 values is entered last... something like:

Code:
me.[Total Cost] = [Product Cost] + [Postage Fee]
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:32
Joined
Jul 2, 2005
Messages
13,826
If the calculation is in the query (that is the RecordSource of the form) and you display the TotalCost query field in a control on the form then it will update as you change values the variable values. No formulas needed on the form. You would want to lock the TotalCost control so the user would not try and make changes there.
 

Users who are viewing this thread

Top Bottom