exit if current record is not a duplicate (1 Viewer)

xveganx007

Registered User.
Local time
Today, 10:06
Joined
Apr 4, 2000
Messages
10
in my form i am currently trying to make it so when i click my command button to exit, it displays a message box if there is a duplicate in the combined fields AUDIT_NO and INDXITMNO (in the record source table for this form there is an index which duplicate values for these 2 controls are not allowed) it prompts an error message instead of just erasing the data that i enter and exiting the form.
here is what i have so far:
Private Sub Command53_Click()
On Error GoTo Err_Command53_Click

Dim strMsg As String

DoCmd.Close acForm, "QA SALP Data - Add screen", acSavePrompt

Exit_Command53_Click:

Exit Sub

Err_Command53_Click:
strMsg = "Cannot Exit, Duplicate Values in Audit # and Index Item # fields"
MsgBox strMsg, vbOKOnly, "Cannot Exit!"
Resume Exit_Command53_Click

End Sub
thanks,
matt
 

Users who are viewing this thread

Top Bottom