Hi all,
When I add a new record and click undo, lets say it was a mistake,,,,
The undo function does not undo the record, see code below.
I am using a code to create a unique ID and it creates a record automatically and that doesnt Undo....
So, what would be the best practice in this to actually remove the record if I add new by mistake and hit Undo?
Would t be better to add a something to the cmdUndo to delete record and then go to Previous or
would it be better to have this code in an unbound field and use an Insert or Update sql on save or Close?
Hope this makes sense as if I hit undo, i dont want a record created with just a UniqueID in it...Code:Private Sub cmdUndoAccount_Click() If (Form.NewRecord) Then Me.Undo DoCmd.GoToRecord , , acPrevious End If If (Not Form.NewRecord) Then Me.Undo End If Call Form_Current Me.cmdUnDoAccount.Enabled = False Me.cmdSaveAccount.Enabled = True End Sub .................................. .................................. 'This will return the last autonumber inserted into the table. It will be unique. 'You can format it into something else for display purposes. Public Function fnHeaderID() As Long Dim sSql As String Dim db As Database sSql = "INSERT INTO tblUniqueIDs (UniqueDate) Values (Now())" Set db = CurrentDb db.Execute sSql, dbSeeChanges fnHeaderID = db.OpenRecordset("SELECT @@IDENTITY")(0) Set db = Nothing End Function
Thanks,
Dave