Could someone please look at the code below and tell me why if the County No is blank it gives me the proper message box but then the form closes anyway? I thought Cancel=True was supposed to stop that.
Dim DataErr As Integer
On Error GoTo err_try
If Me.Dirty And IsNull(Me!COUNTY_NO) Then
Cancel = True
MsgBox "You can not leave COUNTY NO blank. It is a required field. Please enter the correct COUNTY NO.", , "Service of Process Error"
Me!COUNTY_NO.SetFocus
ElseIf Me.Dirty And IsNull(Me!COURT_TYPE_CODE) Then
MsgBox "You can not leave COURT TYPE CODE blank. It is a required field. Please enter the correct COURT TYPE CODE.", , "Service of Process Error"
Me!COURT_TYPE_CODE.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!COURT_NMBR) Then
MsgBox "You can not leave COURT NUMBER blank. It is a required field. Please enter the correct COURT NUMBER.", , "Service of Process Error"
Me!COURT_NMBR.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!CASHIER_NO) Then
MsgBox "You can not leave CASHIER NUMBER blank. It is a required field. Please enter the correct CASHIER NUMBER.", , "Service of Process Error"
Me!CASHIER_NO.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!DOCKET_NO) Then
MsgBox "You can not leave DOCKET NUMBER blank. It is a required field. Please enter the correct DOCKET NUMBER.", , "Service of Process Error"
Me!DOCKET_NO.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!EXCEPTION_CODE) Then
MsgBox "You can not leave EXCEPTION CODE blank. It is a required field. Please enter the correct EXCEPTION CODE.", , "Service of Process Error"
Me!EXCEPTION_CODE.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!TRANS_DATE) Then
MsgBox "You can not leave TRANSACTION DATE blank. It is a required field. Please enter the correct TRANSACTION DATE.", , "Service of Process Error"
Me!TRANS_DATE.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!BATCH_DATE) Then
MsgBox "You can not leave BATCH DATE blank. It is a required field. Please enter the correct BATCH DATE.", , "Service of Process Error"
Me!BATCH_DATE.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!MASTER_CODE) Then
MsgBox "You can not leave MASTER CODE blank. It is a required field. Please enter the correct MASTER CODE.", , "Service of Process Error"
Me!MASTER_CODE.SetFocus
Cancel = True
Else
Exit Sub
End If
exit_unload:
Exit Sub
err_try:
If DataErr = 2279 Then
MsgBox "The EXCEPTION CODE field and the TYPE CLAIM field both require the entry of two letters. Please enter two letters only.", , "Service of Process Error"
Cancel = True
ElseIf Err.Number = 3022 Then
MsgBox "The EXCEPTION CODE, CASHIER NUMBER and DOCKET NUMBER together make up the key to this form. You have entered a combination of those three that already exists in the EXCEPTIONS table. Please try again.", , "Service of Process Error"
Me!EXCEPTION_CODE.SetFocus
Cancel = True
ElseIf Err.Number = 3201 Then
MsgBox "The combination of COUNTY NO, COURT TYPE CODE and COURT NUMBER make up a unique field that identifies a specific court. The COUNTY NO you entered into this combination does not exist. Please re-enter the COUNTY NO.", , "Service of Process Error"
Me!COUNTY_NO.SetFocus
Cancel = True
Else
Resume exit_unload
End If
End Sub
Dim DataErr As Integer
On Error GoTo err_try
If Me.Dirty And IsNull(Me!COUNTY_NO) Then
Cancel = True
MsgBox "You can not leave COUNTY NO blank. It is a required field. Please enter the correct COUNTY NO.", , "Service of Process Error"
Me!COUNTY_NO.SetFocus
ElseIf Me.Dirty And IsNull(Me!COURT_TYPE_CODE) Then
MsgBox "You can not leave COURT TYPE CODE blank. It is a required field. Please enter the correct COURT TYPE CODE.", , "Service of Process Error"
Me!COURT_TYPE_CODE.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!COURT_NMBR) Then
MsgBox "You can not leave COURT NUMBER blank. It is a required field. Please enter the correct COURT NUMBER.", , "Service of Process Error"
Me!COURT_NMBR.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!CASHIER_NO) Then
MsgBox "You can not leave CASHIER NUMBER blank. It is a required field. Please enter the correct CASHIER NUMBER.", , "Service of Process Error"
Me!CASHIER_NO.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!DOCKET_NO) Then
MsgBox "You can not leave DOCKET NUMBER blank. It is a required field. Please enter the correct DOCKET NUMBER.", , "Service of Process Error"
Me!DOCKET_NO.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!EXCEPTION_CODE) Then
MsgBox "You can not leave EXCEPTION CODE blank. It is a required field. Please enter the correct EXCEPTION CODE.", , "Service of Process Error"
Me!EXCEPTION_CODE.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!TRANS_DATE) Then
MsgBox "You can not leave TRANSACTION DATE blank. It is a required field. Please enter the correct TRANSACTION DATE.", , "Service of Process Error"
Me!TRANS_DATE.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!BATCH_DATE) Then
MsgBox "You can not leave BATCH DATE blank. It is a required field. Please enter the correct BATCH DATE.", , "Service of Process Error"
Me!BATCH_DATE.SetFocus
Cancel = True
ElseIf Me.Dirty And IsNull(Me!MASTER_CODE) Then
MsgBox "You can not leave MASTER CODE blank. It is a required field. Please enter the correct MASTER CODE.", , "Service of Process Error"
Me!MASTER_CODE.SetFocus
Cancel = True
Else
Exit Sub
End If
exit_unload:
Exit Sub
err_try:
If DataErr = 2279 Then
MsgBox "The EXCEPTION CODE field and the TYPE CLAIM field both require the entry of two letters. Please enter two letters only.", , "Service of Process Error"
Cancel = True
ElseIf Err.Number = 3022 Then
MsgBox "The EXCEPTION CODE, CASHIER NUMBER and DOCKET NUMBER together make up the key to this form. You have entered a combination of those three that already exists in the EXCEPTIONS table. Please try again.", , "Service of Process Error"
Me!EXCEPTION_CODE.SetFocus
Cancel = True
ElseIf Err.Number = 3201 Then
MsgBox "The combination of COUNTY NO, COURT TYPE CODE and COURT NUMBER make up a unique field that identifies a specific court. The COUNTY NO you entered into this combination does not exist. Please re-enter the COUNTY NO.", , "Service of Process Error"
Me!COUNTY_NO.SetFocus
Cancel = True
Else
Resume exit_unload
End If
End Sub