Hi -

I was wondering if anyone could tell me why the undo command "isn't available" in a form

I'm using it as part of the cancel function on a form. When the form is called from another form to enable the user to add a new record, it is pre-populated with some info from the first form. This of course creates a record in the table using the next autonumber in the sequence. if the user cancels the form though, I want the record to be deleted and the autonumber not to use the next one.

For example:

User clicks Add Entry in form 1 to bring up form 2,

form 2 is populated with info from form 1 and the sequence number is 123,

if the user cancels form 2, the record should be undone,

on calling form 2 again, the sequence number should be 123 - not (as it is) 124.

Make sense

I'm trying to do this using the RunCommand acCmdUndo command, but i get the error message "The command or action 'Undo' isn't available now."

I'm not sure why .. If anyone can point me in the right direction, that would be much appreciated!

Cheers & happy st paddy's day!


Re: Undo is not available?

Luiz Claudio - MVP

Hi Aussie,

it's by design. In order to work correctly in mlti-user environments, Jet discards the ID generated when a new record is opened (even when it's not saved).

Autonumber fields are recommended when you don't need continuous numbering (i.e., when "holes" are acceptable).

To undo the new record, you can use Me.Undo or Forms!YourForm.Undo. You won't have your number sequence restored anyway.

Re: Undo is not available?


hmmm ... by design huh well, at least i wasn't doing something stoopid!! LOL ... no problem; thanks for letting me know; I suppose that makes sense really otherwise it would be pretty hard to programme when to increment or not - easier to just make it increment all the time ... i do need sequential numbers for what i'm doing, but that's ok, i'll just add a count query to the table .. i just didn't want to do that if i was doing something obviously daft!

many thanks for your advice,

aussie james.