Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

After Update event doesn't work if control value set via macro

Status
Not open for further replies.

Prathmesh

Programmer
Oct 22, 2003
21
AU
Hi All.
I have a form wherein based on changes to certain fields (any/all of them), I want to change values to other fields. What I have done is that I have written a macro that automatically updates a flag field as soon as any of the required field is changed. As soon as the flag field is updated, in the after update event macro for that flag field, which is basically a check box, I have written another macro to update the other fields. The foll. sequence explains breifly what I want to do.

Control on form Updated --> Update check box via macro --> after check box updated via macro, update required controls via macro.

Now both the macros run in after update event of the respective controls. The macros basically contain "setValue" commands to update other field values. However, what I am observing is that even though the check box gets updated, the macro in its after update event is not getting fried. In essence, if the value of the check box event is set through a macro, i.e. automatically, the after update event does not work. Whereas if manually the check box value is changed the after update event is fired. What I want to know is that why does this happen? Shouldn't the after update event for the check box, or any other control for that matter, be fired, irrespective of whether the value for that control is updated automatically or manually? Am I missing something important here or is this a potential flaw in MS Access? I would highly appreciate any clarifications for the above.

Thanks to all in advnace for your time and efforts.

Regards.
 
Hi

I think you will find that is expected behaviour setting the value of a control does not trigger the after Update event. But it hardly rocket Science to work around it eg

ChkMyCheckbox = True
ChkMyCheckbox_AfterUpdate

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi

Just to confirm that, from help:

BeforeUpdate, AfterUpdate Events



The BeforeUpdate event occurs before changed data in a control or record is updated.


The AfterUpdate event occurs after changed data in a control or record is updated.

Notes

Changing data in a control by using Visual Basic or a macro containing the SetValue action doesn't trigger these events for the control. However, if you then move to another record or save the record, the form's BeforeUpdate and AfterUpdate events do occur

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi Ken
Many thanks for the input. Actually my question was more intended towards understanding why the after update event doesn't work with setvalue. As you yourself mentioned, its no rocket science to get around that. Your second answer, however helps a lot. And still if u see, only the form's afterupdate and beforeupdate events are triggered, not for the control. Guess Access works that way!!! Thanks really for your time and efforts. Much appreciated.

Regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top