Skip to content

Flag on Editing a Record

How to throw up a flag if someone’s editing an existing record.

Q:  Julie Garret writes to ask if there is a way to throw up a flag if someone edits an existing record.

A:  On a bound form, you can use the form’s BeforeUpdate event for this purpose.  Here is a procedure that cancels the update and undoes the form changes if the user clicks the No button:

Private Sub Form_BeforeUpdate(Cancel As Integer)

 

   Dim intReturn As Integer

   Dim strPrompt As String

  

   strPrompt = “Are you sure you want to edit this record?”

   intReturn = MsgBox(strPrompt, vbQuestion + vbYesNo)

   If intReturn = vbNo Then

      Cancel = True

      Me.Undo

   End If

  

End Sub

About this author

Office 2024 - all you need to know. Facts & prices for the new Microsoft Office. Do you need it?

Microsoft Office upcoming support end date checklist.