I have a database mainly used for lookup and only occasionally edited. In order to avoid any unintended changes, I’m working on Popping a Prompt to confirm edits.
The mentioned DB contains just a single table with around 7k records and no Forms at all.
What I have done is:
- The Before Change Event of the table takes the SetLocalVar action, with the expression set to:
=ConfirmEdit()
- ConfirmEdit() is a VBA Function inside a Non-Class Module:
Option Compare Database
Public Function ConfirmEdit()
If MsgBox("Are you sure you want to make this change?", vbQuestion + vbYesNo, "Confirm Edit") = vbNo Then
DoCmd.RunCommand acCmdUndo
End If
End Function
Problem is, despite achieving the intended behavior, it show a warning when user cancels the edit.
First it shows this:
Followed by This after Clicking No:
As far as I know, I can’t use Me keyword as the code is not inside a class module to do something like Me.Undo
.
Is there any solution not to raise that error or any workaround to just hide it?!