G
Guest
Is this possible to accomplish?
A field (MyField) contains some text. When a user changes or deletes that
text, I display a message box asking the user if he really wanted to change
the text in MyField. The way my code is set up, the message box displays
after every data change. (I'm not very good at writing code.)
Dim ChgAnswer As Integer, MsgTitle As String, MsgDialog As Integer
Const MB_YESNO = 4
Const MB_ICONEXCLAMATION = 48
Const MB_DEFBUTTON1 = 0, IDYES = 6, IDNO = 7
If Not IsNull(Me.MyField) Then
Beep
MsgTitle = "Data Change"
MsgDialog = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON1
ChgAnswer = MsgBox("Do you really want to change the data in this
field?", MsgDialog, MsgTitle)
If ChgAnswer = IDNO Then
Me.Undo
End If
End If
I want the message box to appear ONLY if MyField already contained a value.
If the field was null, I don't want the message box to display.
What's the best event to use for this purpose? (I'm currently using
BeforeUpdate.) Can anyone help clean up my code?
Thanks very much.
A field (MyField) contains some text. When a user changes or deletes that
text, I display a message box asking the user if he really wanted to change
the text in MyField. The way my code is set up, the message box displays
after every data change. (I'm not very good at writing code.)
Dim ChgAnswer As Integer, MsgTitle As String, MsgDialog As Integer
Const MB_YESNO = 4
Const MB_ICONEXCLAMATION = 48
Const MB_DEFBUTTON1 = 0, IDYES = 6, IDNO = 7
If Not IsNull(Me.MyField) Then
Beep
MsgTitle = "Data Change"
MsgDialog = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON1
ChgAnswer = MsgBox("Do you really want to change the data in this
field?", MsgDialog, MsgTitle)
If ChgAnswer = IDNO Then
Me.Undo
End If
End If
I want the message box to appear ONLY if MyField already contained a value.
If the field was null, I don't want the message box to display.
What's the best event to use for this purpose? (I'm currently using
BeforeUpdate.) Can anyone help clean up my code?
Thanks very much.