I have a database form with a combo box. I want to ascertain if data has been entered into this box before closing the form.
My code below only works when data has been entered and deleted in the combo field, but not on records where this particualr field has never populated.
Any thoughts on this appreciated...
------------------
Private Sub btnClose_Click()
Dim strEnquiryMissing As String
On Error GoTo Err_btnClose_Click
DoCmd.RunCommand acCmdSaveRecord
cmbEnquiryType.SetFocus
If IsNull(Me!cmbEnquiryType) Then
MsgBox ("You must provide an enquiry category for this record")
Else
Forms![frmsmclient]![sbfrmCommentList].Requery
Forms![frmsmclientb3]![sbfrmCommentList].Requery
DoCmd.Close
End If
Exit_btnClose_Click:
Exit Sub
Err_btnClose_Click:
DoCmd.Close
End Sub
My code below only works when data has been entered and deleted in the combo field, but not on records where this particualr field has never populated.
Any thoughts on this appreciated...
------------------
Private Sub btnClose_Click()
Dim strEnquiryMissing As String
On Error GoTo Err_btnClose_Click
DoCmd.RunCommand acCmdSaveRecord
cmbEnquiryType.SetFocus
If IsNull(Me!cmbEnquiryType) Then
MsgBox ("You must provide an enquiry category for this record")
Else
Forms![frmsmclient]![sbfrmCommentList].Requery
Forms![frmsmclientb3]![sbfrmCommentList].Requery
DoCmd.Close
End If
Exit_btnClose_Click:
Exit Sub
Err_btnClose_Click:
DoCmd.Close
End Sub