I have the following events on a form. The first one checks to see if one field is checked, the other field must not be null. It prompts correctly, but it allows the user to close the form. I need it to remain open and set focus on [OES] field.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.IDJob) Then
If IsNull(Me.OES1) Then
MsgBox "ID Job Vacancies is checked. You must enter an OES Code.", vbInformation
DoCmd.CancelEvent
DoCmd.GoToControl "OES1"
Exit Sub
End If
End If
End Sub
AND THIS ON MY COMMAND BUTTON TO CLOSE:
Private Sub closefrm_Click()
On Error GoTo Err_closefrm_Click
DoCmd.Close
Exit_closefrm_Click:
Exit Sub
Err_closefrm_Click:
MsgBox Err.Description
Resume Exit_closefrm_Click
End Sub
Thanks,
Z
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.IDJob) Then
If IsNull(Me.OES1) Then
MsgBox "ID Job Vacancies is checked. You must enter an OES Code.", vbInformation
DoCmd.CancelEvent
DoCmd.GoToControl "OES1"
Exit Sub
End If
End If
End Sub
AND THIS ON MY COMMAND BUTTON TO CLOSE:
Private Sub closefrm_Click()
On Error GoTo Err_closefrm_Click
DoCmd.Close
Exit_closefrm_Click:
Exit Sub
Err_closefrm_Click:
MsgBox Err.Description
Resume Exit_closefrm_Click
End Sub
Thanks,
Z