View Full Version : Calculating fields within a Record


chuckster
10-04-2000, 01:39 AM
I want to calculate a field based on the values of others fields in the same record.
I have put an equation in the control source property which generates the correct result but this doesn't write the result into the table that the form is linked to.

Atomic Shrimp
10-04-2000, 02:16 AM
if you want to do this, you'll need to do an update query on the table, but if you can calculate a value on the fly from data in your table, it's usually best to do just that and not to store it.

Mike

chuckster
10-04-2000, 04:09 AM
Cheers. Makes sense.

russi
10-05-2000, 07:30 AM
Hope this helps. It let me do a calculation for a field and have the value saved in the table, without using a separate update query on the whole table.

On data entry form, I made the field that I want to store info (ie, AGE_AT_APPLICATION, invisible. Then I added an unbound text box (ie, AGE_CALCULATION) which had as Control Source the calculation itself.

On each field involved in doing the calculation I added an AfterUpdate code of: Me.AGE_AT_APPLICATION = Me.AGE_CALCULATION

IT then shows the age automatically in the form's AGE_CALCULATION field and automatically stores the age in the AGE_AT_APPLICATION field in the table.

Hope this helps.