I have a field, agency_id (exit event)with the following code below. If this error exists, I do not want to save the record. I've tried adding the code in the close, deactivate, unload events of the form. That does not seem to work. What's a good solution for preventing the save when there is an error?
If Len(Agency_ID) <> 3 Then
MsgBox "Please enter 3 numbers for Agency ID"
DoCmd.GoToControl "Agency_ID"
End If
If Len(Agency_ID) <> 3 Then
MsgBox "Please enter 3 numbers for Agency ID"
DoCmd.GoToControl "Agency_ID"
End If