Lifeseeker
Registered User.
- Local time
- Today, 05:07
- Joined
- Mar 18, 2011
- Messages
- 273
Hi,
I have a form-based search. The code is as follows:
Private Sub Command7_Click()
If Len(cbosearchfield) = 0 Or IsNull(cbosearchfield) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtsearchstring) = 0 Or IsNull(txtsearchstring) = True Then
MsgBox "You must enter a search string."
Else
'Generate search criteria
GCriteria = "[" & cbosearchfield.Value & "]" & " LIKE '*" & txtsearchstring & "*'"
'Filter frmCustomers based on search criteria
Form_frm_fee_history_browse.RecordSource = "select * from fee where " & GCriteria
Form_frm_fee_history_browse.Caption = "fee (" & cbosearchfield.Value & " contains '*" & txtsearchstring & "*')"
'Close frmSearch
'DoCmd.Close acForm, "frm_lab_Search"
MsgBox "Item Found!"
DoCmd.Close acForm, "frm_search"
End If
End Sub
If an item cannot be found, it will still say "Item Found!". How should the code look like that represents the situation where a search returns no result?
comments/thoughts much appreciated
I have a form-based search. The code is as follows:
Private Sub Command7_Click()
If Len(cbosearchfield) = 0 Or IsNull(cbosearchfield) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtsearchstring) = 0 Or IsNull(txtsearchstring) = True Then
MsgBox "You must enter a search string."
Else
'Generate search criteria
GCriteria = "[" & cbosearchfield.Value & "]" & " LIKE '*" & txtsearchstring & "*'"
'Filter frmCustomers based on search criteria
Form_frm_fee_history_browse.RecordSource = "select * from fee where " & GCriteria
Form_frm_fee_history_browse.Caption = "fee (" & cbosearchfield.Value & " contains '*" & txtsearchstring & "*')"
'Close frmSearch
'DoCmd.Close acForm, "frm_lab_Search"
MsgBox "Item Found!"
DoCmd.Close acForm, "frm_search"
End If
End Sub
If an item cannot be found, it will still say "Item Found!". How should the code look like that represents the situation where a search returns no result?
comments/thoughts much appreciated