S
spacerocket
How do I display a message box if a search does not have any match? I got
this code that works, but if the search doesn't match, it shows a filtered
form which is blank. Thanks a lot.
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "Please select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "Please enter a search string."
Else
strWhere = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
Form_F_Contacts_NoEdit.RecordSource = "select * from Contacts where
" & strWhere
Form_F_Contacts_NoEdit.Caption = "Contacts (" & cboSearchField.Value
& " contains '*" & txtSearchString & "*')"
DoCmd.Close acForm, "F_Search"
MsgBox "Search completed."
End If
this code that works, but if the search doesn't match, it shows a filtered
form which is blank. Thanks a lot.
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "Please select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "Please enter a search string."
Else
strWhere = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
Form_F_Contacts_NoEdit.RecordSource = "select * from Contacts where
" & strWhere
Form_F_Contacts_NoEdit.Caption = "Contacts (" & cboSearchField.Value
& " contains '*" & txtSearchString & "*')"
DoCmd.Close acForm, "F_Search"
MsgBox "Search completed."
End If