I am trying to say that if cboSource or cboWorkType is null, display a message and then go back to the field on the form that is null. Problem is, the form closes displaying the message. Below is what it is doing:
Below is the code I am using:
1. I hit OK button to close form
2. Message box displays saying cboSource is null.
3. I hit OK to close the Message box
4. Form closes
2. Message box displays saying cboSource is null.
3. I hit OK to close the Message box
4. Form closes
Below is the code I am using:
Code:
Private Sub Form_AfterUpdate()
If IsNull(Me!cboSource) Then
MsgBox ("The ""Source"" must be entered."), vbCritical, gstrAppTitle
Me!cboSource.SetFocus
ElseIf IsNull(Me!cboWorkType) Then
MsgBox ("The ""Work Type"" must be entered."), vbCritical, gstrAppTitle
Me!cboWorkType.SetFocus
Else
DoCmd.Close acForm, "fdlgContractDetail", acSavePrompt ' User wants to save and close the form
End If
End Sub
Private Sub cmdOK_Click()
On Error GoTo ErrorHandler
DoCmd.Close acForm, "fdlgJobDetail", acSavePrompt ' User wants to save and close the form
CleanUpAndExit:
Exit Sub
ErrorHandler:
Call MsgBox("An error was encountered" & vbCrLf & vbCrLf & _
"Description: " & Err.Description & vbCrLf & _
"Error Number: " & Err.Number, vbCritical, gstrAppTitle)
Resume CleanUpAndExit
End Sub