I have a database that has several forms. These forms are of course tied to tables that have required fields. I am trying to capture the Error number 3314 which is generated when a new record is added and a field on the form is left blank that is tied to a required field in the table.
I have tried Before/After insert, Before/After Update, and On Error. My code is:
If Err.Number = 3314 Then
errSource = Err.Source
Select Case errSource
Case Is = "txt_MRRNo"
errorSource = "MRR Number"
criticalErrFlag = True
Case Is = "cmb_InspStatus"
errorSource = "Inspection Status"
criticalErrFlag = True
Case Is = "txt_CurrentAssignedTo"
errorSource = "Assigned To - Current"
criticalErrFlag = True
Case Is = "txt_AssignedDate" Or "txt_AssignedTime"
errorSource = "Assigned Date / Time"
criticalErrFlag = True
Case Is = "cmbMtrlType"
errorSource = "Material Type"
Case Is = "txt_BeginInspDate" Or "txt_BeginInspTime"
errorSource = "Begin Date / Time"
End Select
If criticalErrFlag = True Then
MsgBox errorSource & " is a required field" & Chr(13) & Chr(13) & _
"This field should have auto populated when you assigned/reassigned" & Chr(13) & _
"this MRR. This means that a system bug exists. An email will be generated" & Chr(13) & _
"and sent to the developer of this system.", vbCritical, "MISSING SYS GEN REQUIRED DATA"
'........................
'Generate Email Message
',,,,,,,,,,,,,,,,,,,,,,,,,
DoCmd.SendObject acSendNoObject, , , "sjellert@Companyname.com", , , "MRR Status Auto fill Error", "Main Data form - QC Information Tab" & Chr(13) & _
"Field: " & errorSource & Chr(13) & _
"MRR Number: " & Parent!cmb_MRRNo & Chr(13) & _
"User: " & mod_MS_Security.LoggedIn_User, False
Me.Undo
Exit Sub
ElseIf criticalErrFlag = False Then
MsgBox errorSource & " is a required field" & Chr(13) & Chr(13) & _
"You must enter this data prior to moving on.", vbCritical, "MISSING REQUIRED DATA"
Me.[errSource].SetFocus
Exit Sub
End If
End If
I have tried Before/After insert, Before/After Update, and On Error. My code is:
If Err.Number = 3314 Then
errSource = Err.Source
Select Case errSource
Case Is = "txt_MRRNo"
errorSource = "MRR Number"
criticalErrFlag = True
Case Is = "cmb_InspStatus"
errorSource = "Inspection Status"
criticalErrFlag = True
Case Is = "txt_CurrentAssignedTo"
errorSource = "Assigned To - Current"
criticalErrFlag = True
Case Is = "txt_AssignedDate" Or "txt_AssignedTime"
errorSource = "Assigned Date / Time"
criticalErrFlag = True
Case Is = "cmbMtrlType"
errorSource = "Material Type"
Case Is = "txt_BeginInspDate" Or "txt_BeginInspTime"
errorSource = "Begin Date / Time"
End Select
If criticalErrFlag = True Then
MsgBox errorSource & " is a required field" & Chr(13) & Chr(13) & _
"This field should have auto populated when you assigned/reassigned" & Chr(13) & _
"this MRR. This means that a system bug exists. An email will be generated" & Chr(13) & _
"and sent to the developer of this system.", vbCritical, "MISSING SYS GEN REQUIRED DATA"
'........................
'Generate Email Message
',,,,,,,,,,,,,,,,,,,,,,,,,
DoCmd.SendObject acSendNoObject, , , "sjellert@Companyname.com", , , "MRR Status Auto fill Error", "Main Data form - QC Information Tab" & Chr(13) & _
"Field: " & errorSource & Chr(13) & _
"MRR Number: " & Parent!cmb_MRRNo & Chr(13) & _
"User: " & mod_MS_Security.LoggedIn_User, False
Me.Undo
Exit Sub
ElseIf criticalErrFlag = False Then
MsgBox errorSource & " is a required field" & Chr(13) & Chr(13) & _
"You must enter this data prior to moving on.", vbCritical, "MISSING REQUIRED DATA"
Me.[errSource].SetFocus
Exit Sub
End If
End If