Dim MyCheck As Variant, MySQL As Variant, MyAnswer As Variant
MySQL = BuildCriteria("ExRefNum", dbText, "ST-" & Format([Forms]![Condition]![TagID], "0000000"))
MyCheck = DLookup("PID", "P Log", MySQL)
If Not IsNull(MyCheck) Then
MyAnswer = MsgBox("This Tag has already been added to the Priority Log!" & Chr(10) & Chr(13) & Chr(10) & Chr(13) & "Do you want to overwrite the record?", vbYesNo, "Record Found!")
If MyAnswer = vbYes Then
DoCmd.SetWarnings (False)
DoCmd.OpenQuery "Delete Tags from P Log"
DoCmd.OpenQuery "Transfer Tags to P Log"
DoCmd.SetWarnings (True)
MsgBox "This Tag has been added to the P Log", vbOKOnly, "Record Added"
End If
Else: DoCmd.SetWarnings (False)
DoCmd.OpenQuery "Transfer Tags to P Log"
DoCmd.SetWarnings (True)
MsgBox "This Tag has been added to the P Log", vbOKOnly, "Record Added"
End If
DoCmd.GoToRecord , , acNewRec
Exit_btn_Save_Click:
Exit Sub
Err_btn_Save_Click:
MsgBox Err.Description
Resume Exit_btn_Save_Click
Please check what I am doing wrong