JF Bouthillier said:
Hi all,
Can someone tell me how I can run the Before Update event
before changing pages within a form?
BeforeUpdate runs any time the record is saved. So if you want to force it
to run you can just issue a command that will save the record.
Me.Dirty = False
Of course if the record was not Dirty then the BeforeUpdate will still not
run. So you can be sure it's dirty with...
Me!SomeField = Me!SomeField
Me.Dirty = False
If by "...changing pages..." you mean navigating to a different record then
as long as the current record has been changed BeforeUpdate will
automatically fire when you navigate. You would not need the Me.Dirty =
False. If you want it to fire even when the user has not changed the
record then you could use...
Me!SomeField = Me!SomeField
....in the Form's Current event. That would make every record looked at in
the form Dirty and thus cause the BeforeUpdate to fire when you leave that
record. I'm not sure that would be a great idea though.
You could always put the code you have in BeforeUpdate into a separate
sub-routine and call it from multiple places. Once from the BeforeUpdate
event and again from any other event where you think it necessary.