Writing an Error Message

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

I am wondering if there is a way to make it so that if
someone updates a certain type of record (PayDenyReturn
= "D") on a form then when they try and scroll off the
record a message box will come up saying something like:

"Do you really want to update this record? This record
is a denied claim and should not be updated, if this is
really what you meant to do, then click Yes, if not and
you would like to undo the changes you have made then
click No"

Then it would do what the message said, go to the next
record and save the previous if you click Yes, or undo
the changes to the current record.

Any help would be great!! I am using Access 2002.

-Michael
 
Use the BeforeUpdate event procedure of the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Do you really ..."

If Me.PayDenyReturn = "D" Then
If MsgBox(strMsg, vbYesNo+vbDefaultButton2) = vbNo Then
Cancel = True
Me.Undo
End If
End If
End Sub
 
Back
Top