Calculations on Record Change

gmatriix

Registered User.
Local time
Today, 14:33
Joined
Mar 19, 2007
Messages
365
Hello All,

I have a form and some calculations in vba I would like to perform when any record on the form is changed.

I know I can do this on the control level but I want to just have one code that does all the calculation on the form level. I cannot figure out which event will trigger the calculations immediately after the record is changed.

I can get it to do it but I have to move the record first and then it will show results.

Is there anyway to perform these calculations immediately when a record on the form has been changed?

Any Ideas?

Thanks
 
The Form Dirty would be triggered as soon as some change is made to the data on the Form..
 
Thanks.....what if the record that you are changing is need to perform the calculation? I believe on dirty will not wait until you enter the value then calculate will it? or am I wrong.....
 
I believe on dirty will not wait until you enter the value then calculate will it? or am I wrong.....
No, you are not wrong.. I picked up on your original premise..
I have a form and some calculations in vba I would like to perform when any record on the form is changed.
:
Is there anyway to perform these calculations immediately when a record on the form has been changed?
However your second post...
what if the record that you are changing is need to perform the calculation?
suggests something different.. This would IMO go into the Control's BeforeUpdate event..
 
So do I have to put calculation on each control that will calculate if it is changed? I guess I was trying to find a way to do this with one code.

Or could I have one fuction and have each control refer to the function?

Thanks
 
Yes, you can create one function and all the BeforeUpdate events can call that one function..
 
i agree with Pat #8 in general terms, although it all depends on the timing you actually need.

if a record has changed in any way, when it gets saved, the beforeupdate event and afterupdate event happens, and therefore you can do general housekeeping there. If you want to change the record BEFORE the save or validate the changes and potentially cancel the update, then beforeupdate. If it is something that occurs as a result of the change then maybe afterupdate is better.

HOWEVER - if you want to change things DURING the record edit, then you need to do it a different point. The problem with using the dirty event is you only get it once. THe first change makes a record dirty, and other changes don;t make it dirty again?

the safest way might be to put code on every control box - although as you say, it can be a lto of work.
 

Users who are viewing this thread

Back
Top Bottom