If you want to do something at the point when the navigates to a different
record, use Form_Current. (Test Me.NewRecord if you want to see if it's a
new record.)
If you want to do something before a record is saved, use Form_BeforeUpdate.
Example: validation of the record.
If you need to do something else as a consequence of editing/inserting a
record, use Form_AfterUpdate or Form_AfterInsert.
If you want to do something at the point when they start entering a new
record, use Form_BeforeInsert.
If you need to reset a form to its previous state when the user discards
changes, use Form_Undo. Example: showing/hiding controls.
If you need to test or respond to deletions, you need a combination for
Form_Delete, Form_BeforeDelConfirm, and Form_AfterDelConfirm. (These are a
bit more complex, as it's possible to select several records and delete them
in one go.)
In general, I don't bother coding buttons for next, previous, save, new, or
undo. The built-in ones work better and are more flexible, and you can put
them on a toolbar or ribbon and use them with any form.
Particularly, undo on a form (rather than toolbar/ribbon) works poorly: if
you have an incomplete value (e.g. if you have typed 2/2/ into a date
field), you can't get out of the text box to get to the button on your form,
but you can get to the toolbar/ribbon button.
HTH
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
BBC via AccessMonster.com said:
I agree, you are absolutely right, I'm not fully aware of events
particularly
around record navigation, saving records, new records, undo etc., and I
know
this is the big hammer method. I am hopefully getting to be an
intermediate
at Access but I have spent probably 100s of hours just trying to get to a
solid set of record navigation functions working (next, previous, save,
new,
undo, integrated with managing "dirty" records...). I have many Access
books
(beginner, Intermediate. Advanced and not one of them treats "navigation"
adequately, at best, bits & pieces) and I have looked at many Forums &
Access
sites, submitted numerous questions but have not found much help in
actually
designing a fully functional solution. I you know of somewhere I can find
some solid practical information with some good examples that would be
great.
I'm pretty good at working through and understanding sample code.
Don't mean to whine, but how hard should this be?
Thanks for input and as I mentioned a few days ago to you, Great Web Site
Allen said:
Yes: cancelling Form_BeforeUpdate will work if you really must force users
through your particular funnel.
There may be times when you might need to do that, but the vast majority
of
times I see people doing this, it's because they don't understand how to
work with the built-in events.
Have a similar issue and want ONLY my save button to save records. Was
wondering if the following strategy might also work.
[quoted text clipped - 30 lines]
How can I prevent the PageDown key from hi-jacking my form.