PDA

View Full Version : My expression on a form won't save to the table



NFFC_Evans
04-24-2007, 11:22 AM
Hey, I have an expression that calculates the 'change' a customer is due based on deducting the item price from the amount tendered;

=[Amount Taken]-[Price]

(this is the control source for my text box). The box successfully calculates and displays the amount of change the customer should receive, yet the value does not get saved as a record in my table.

Does anyone know some code/expression that will save this particular value to the table, (afterupdate maybe)? I have tried DoCmd.Save to no avail.

Thank you for reading :)

omocaig
04-24-2007, 12:31 PM
You shouldn't store the results of a calculation in a table. If you need to know the change due at a later time you can just query it out.

hth,
Giacomo

GaryB
04-24-2007, 04:54 PM
Hi,

When you do an automatic calculation, such as yours, Access, to the best of my knowledge does not save the results to the table. It will still be saved in the form, if you are creasting a new record each time you use it. I haven't found a way around this, but maybe some of the super minds on this forum have.

Good Luck

Gary

OBP
04-25-2007, 03:11 AM
The reason that Access can't save it to the table is because the Record source is the function instead of the table.
As omocaig says you should not really store the results of calculations in a table, unless it makes some other "difficult" calculation easier by doing so, like using Cross Tab or Grouping Queries or Graphs.
So if the data must be saved, to overcome the problem, use a Function in a Query or some VBA to do the calculation instead of a function in the form.