message appearing more than onces ...

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
 
S

Steve Schapel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top