G
Guest
I have a form with the below code in the BeforeUpdate event.
I created a 'New Record' button: DoCmd.GoToRecord , , acNewRec
and a 'Close' button: DoCmd.Close, but they aren't working right. When
they are clicked the message box "Do you want to save this new log?" appears
(which it should). However, even if a user clicks "yes" to save a log, the
DoCmd.GoToRecord or DoCmd.Close are carried out. How can I stop the going to
a new record or closing if a user wants to save the log? Thanks.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
If MsgBox("Do you want to save this new log?", vbYesNo) = vbNo Then
Cancel = True
Me.Undo
Exit Sub
End If
End If
If IsNull(Me.Part__) Then
MsgBox "There is information missing.", vbOKOnly
Cancel = True
End If
End Sub
I created a 'New Record' button: DoCmd.GoToRecord , , acNewRec
and a 'Close' button: DoCmd.Close, but they aren't working right. When
they are clicked the message box "Do you want to save this new log?" appears
(which it should). However, even if a user clicks "yes" to save a log, the
DoCmd.GoToRecord or DoCmd.Close are carried out. How can I stop the going to
a new record or closing if a user wants to save the log? Thanks.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
If MsgBox("Do you want to save this new log?", vbYesNo) = vbNo Then
Cancel = True
Me.Undo
Exit Sub
End If
End If
If IsNull(Me.Part__) Then
MsgBox "There is information missing.", vbOKOnly
Cancel = True
End If
End Sub