Refire an Afterupdate Event

jneirinckx

Registered User.
Local time
Today, 09:26
Joined
Feb 28, 2004
Messages
133
Good morning,
We have a form where we enter asset data. Based on input I have an Afterupdate event fire to assign a category to the asset. This all works fine.

We now have changed the criteria in the calculation which again is fine but only is being applied to new records. Is there a way to refire/recalculate that Afterupdate event for exsisting records as it would be a lot of work to go back through about 1500 records and manually refire that event.

Thanks for any ideas/advice you can give.
Jerry
 
Hi Jerry, Well a cheeky way would be to call the AfterUpdate property manually through the FormCurrent method.. But you would have to open the form and navigate through all records.. you can also do that programmatically.. THIS IS NOT THE BEST OPTION.. but is one fix.. something like..

Code:
Privare Sub Form_Current
      Call field_Name_After_Update
End Sub
Then create a module, that will open the form and navigate till the end of the records.. something like..

Code:
Private Sub runCmd
 DoCmd.OpenForm "form_name", acNormal
 For i=0 to DCount("field_name","table_name")-1
     DoCmd.GoToRecord , , acNext
 Next
 DoCmd.Close acForm, "form_name"
End Sub
Hope this makes some sense.. Please restrain to this as the last solution, there might be better solutions..
 
Running an Update query might be all you need.
 
Using an Update Query would be the standard approach, here.

Linq ;0)>
 
Thanks to everyone for their help. The code in the oncurrent event of the form did the job.

Thanks again.
Jerry
 
I hope you are not using the AfterUpdate of the form to assign a value to the current record. That puts the form into a loop because you are dirtying the record after it was saved causing it to be dirtied again and in need of saving after which you dirty it again, etc. Newer versions of Access stop the recursion after a few iterations but earlier ones go into a tight loop and never come back.

If you want to modify the current record, the code belongs in the BeforeUpdate event.
 

Users who are viewing this thread

Back
Top Bottom