message appearing more than onces ...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In new record, I enter all the fields, when I click on the next record arrow,
I get the message correctly - 'Do you want to Save Changes'
yes/no/cancel,

if I choose No, it clear all the fields, but I get the message again, can
someone help me in fixing this please?

I have the following code in my form -

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ivalue
ivalue = Int(0)
ivalue = (MsgBox("Do you want to Save Changes? ", 547, "Update"))
If ivalue = 2 Then
DoCmd.CancelEvent
Exit Sub
ElseIf ivalue = 6 Then
[UPDATE_DATE] = Now
DoCmd.Save
Exit Sub
Else:
Form.Undo
Exit Sub
End If

Thank you,
-Me
 
Me,

Try it like this...

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ivalue As Integer
ivalue = MsgBox("Do you want to Save Changes? ", 547, "Update")
If ivalue = 2 Then
Cancel = True
ElseIf ivalue = 6 Then
Me![UPDATE_DATE] = Now
Else
Cancel = True
Me.Undo
End If
 
Back
Top