I have a very simple code that I got from Microsoft to Confirm record changes. Now, on each of my forms, I have to put that code into the before update. Can I not just make 1 module and refer to the module in each before update? There has to be an easier way. I at least got to the create module and now have a module as shown:
Option Compare Database
Option Explicit
Public Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim iResponse As Integer
' Specify the message to display.
strMsg = "Do you wish to save the changes?" & Chr(10)
strMsg = strMsg & "Click Yes to Save or No to Discard changes."
' Display the message box.
iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")
' Check the user's response.
If iResponse = vbNo Then
' Undo the change.
DoCmd.RunCommand acCmdUndo
' Cancel the update.
Cancel = True
End If
End Sub
I named that module ConfirmChanges, but when i go to a form, and enter ConfirmChanges in the BeforeUpdate box, I get an error. Thanks for your help.
Option Compare Database
Option Explicit
Public Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim iResponse As Integer
' Specify the message to display.
strMsg = "Do you wish to save the changes?" & Chr(10)
strMsg = strMsg & "Click Yes to Save or No to Discard changes."
' Display the message box.
iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")
' Check the user's response.
If iResponse = vbNo Then
' Undo the change.
DoCmd.RunCommand acCmdUndo
' Cancel the update.
Cancel = True
End If
End Sub
I named that module ConfirmChanges, but when i go to a form, and enter ConfirmChanges in the BeforeUpdate box, I get an error. Thanks for your help.