Teri Bridges
Member
- Local time
- Yesterday, 18:22
- Joined
- Feb 21, 2022
- Messages
- 187
I have the following code written so that when a user does not want to save the data they entered they can opt not to save changes. I noticed that the autonumbering generates a number but does not save it.
So if the user enters record # 4 and they decide not to save it the # 4 line item is deleted and the next record entry is 5. i was wondering if there is a way for that not to happen. If they decided not to save entry #4 then # 4 would be the next available entry.
So if the user enters record # 4 and they decide not to save it the # 4 line item is deleted and the next record entry is 5. i was wondering if there is a way for that not to happen. If they decided not to save entry #4 then # 4 would be the next available entry.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim answer As Integer
answer = MsgBox("Save Changes?", vbQuestion + vbYesNo + vbDefaultButton2, "Change Prompt")
If answer = vbYes Then
DoCmd.Save
Else
Me.Undo
End If
End Sub