How undo record but don't use the record number

I have this code to undo a record entry on a form, but it seems to use the PK number and I don't want it to do so.  I can I prevent that from happening?  When I attempt to then enter a new record the PK number has been used.

Private Sub cmdUndoRecord_Click()
On Error GoTo cmdUndoRecord_Click_Err

    On Error Resume Next
    DoCmd.RunCommand acCmdUndo
    If (MacroError <> 0) Then
        MsgBox MacroError.Description, vbOKOnly, ""
    End If

    Exit Sub

    MsgBox Error$
    Resume cmdUndoRecord_Click_Exit

End Sub

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:

 You can't prevent that from happening.  With a ACE database, the autonumber is assigned as soon as a record is started.  With some DB's it's not done until after a record is saved, but that's not the way it works with ACE.

You can assign your own number if you want, but I have to say, you should not be counting on the value of that anyway.  It's nothing more then a "tag" or "pointer" for the record and is meaningless out of that context.

If your trying to use it for something else, your using the wrong thing.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveL13Author Commented:
Ok.  Thanks Jim.  We will live with it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.