Cosmos75
Registered User.
- Local time
- Today, 04:27
- Joined
- Apr 22, 2002
- Messages
- 1,281
I have a macro in the beforeupdate that always asked the user if they want to change the current record, if the click OK, the changes are accepted, if the click NO, then the macro runs a CancelEvent, and the user then has to clear his or her changes by clicked ESC. This is great to make sure a user doesn't accidentally change an entered record.
HOWEVER, this macro also runs when a NEW record is trying to be added. Is there a condition I can add in the macro to not run when a new recored is being added?
I've converted the macro to Visual Basic in case that helps.
Function ConfrimEdit()
On Error GoTo ConfirmEdit_Err
If (MsgBox("Accept changesl? If NO, then click Cancel and then ESC. Pressing EQC clears the changes made and allows you to move to another record.", 1, "Are you sure?") = 2) Then
DoCmd.CancelEvent
' Perform the action on this line if the condition on the preceding line is true
SendKeys "{ESC}", False
End If
CEdit2_Exit:
Exit Function
CEdit2_Err:
MsgBox Error$
Resume CEdit2_Exit
End Function
HOWEVER, this macro also runs when a NEW record is trying to be added. Is there a condition I can add in the macro to not run when a new recored is being added?
I've converted the macro to Visual Basic in case that helps.
Function ConfrimEdit()
On Error GoTo ConfirmEdit_Err
If (MsgBox("Accept changesl? If NO, then click Cancel and then ESC. Pressing EQC clears the changes made and allows you to move to another record.", 1, "Are you sure?") = 2) Then
DoCmd.CancelEvent
' Perform the action on this line if the condition on the preceding line is true
SendKeys "{ESC}", False
End If
CEdit2_Exit:
Exit Function
CEdit2_Err:
MsgBox Error$
Resume CEdit2_Exit
End Function