ctrl+F9

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working with Access XP (2002)

when working with new records and particularly the me.undo command,
ctrl+F9 seems to perform what I expect doCmd.save to do.

If I use the vb docmd.save -something happens, but the record is still
undoable
all the way back to the status of the record when the form first opened.

Yet, if I do a ctrl+F9, add more changes, I am able to undo only to the last
time I pressed ctrl+F9

what is the equivalent vb command for ctrl+F9? or do I have to use sendkey?

I don't want to do a requery on the form, because I'll have to write code to
bring me back to the current record.
 
DoCmd.Save is for saving changes to the design of objects: it has
nothing to do with saving new or edited records. The latter are normally
saved automatically whenever the form moves to a new record. If you want
to force data to be written to the table before then, the idiom is,
surprisingly,
Me.Dirty = False

It's probably more common to let the changes be made on the form and
then allow the user to decide whther or not to commit them by writing
code in the form's BeforeUpdate event procedure.

If you're interested in undoing things, check out the OldValue property
of most Access controls.
 
There's a difference between Undo and Delete. You can undo anything that has
been entered on the screen prior to that record being saved. Once you save
the record, you can no longer undo, you must delete the record. Likewise,
you can't delete a record prior to it being saved.
 
Thanks John,
That's interesting about me.dirty = false

I'm repairing a bad design of code someone else wrote.
Apparently, the previous programmer avoided using beforeupdate in the
interest of some unusual functionality.

Rather than rewrite all that code, I opted in favor of sendkeys "^{F9}"
Which did the trick.

Make a change, save it... make two changes, undo - and only two changes
should be undone, not 3.

Thanks for the info.
 
Your comment does not even address my question which is:
"What is the vba equivalent of ctrl+F9"

Thanks anyway
 
I'm at a disadvantage because I don't know what Ctrl+F9 does and can't
find it in Help. But I got the impression that it's doing the same thing
as Me.Dirty, which is why I suggested that.

Sendkeys should always be an absolute last resort. If you can direct me
to a help page that describes Ctrl+F9 it should be possible to find a
VBA equivalent. (It's also worth checking whether this is a shortcut
created by the original developer: is it in an Autokeys macro?)
 
Back
Top