S
spacerocket
I'm doing a contacts db, and have a search form that contains a combobox for
user to select the field (cboSearchField) to search and a text box for
entering the search criteria (txtSearchString).
How do I search for more than one fields? I would like to be able to search
for the fields PhoneNo1, FaxNo & MobileNo after entering a phone no. in the
search string. Based on the code which I got from a tutorial, I manage to
search successfully, but only within 1 field.
strWhere = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
Form_F_Contacts.RecordSource = "select * from Contacts where " & strWhere
Form_F_Contacts.Caption = "Contacts (" & cboSearchField.Value & " contains
'*" & txtSearchString & "*')"
DoCmd.Close acForm, "F_Search"
MsgBox "Search completed."
user to select the field (cboSearchField) to search and a text box for
entering the search criteria (txtSearchString).
How do I search for more than one fields? I would like to be able to search
for the fields PhoneNo1, FaxNo & MobileNo after entering a phone no. in the
search string. Based on the code which I got from a tutorial, I manage to
search successfully, but only within 1 field.
strWhere = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
Form_F_Contacts.RecordSource = "select * from Contacts where " & strWhere
Form_F_Contacts.Caption = "Contacts (" & cboSearchField.Value & " contains
'*" & txtSearchString & "*')"
DoCmd.Close acForm, "F_Search"
MsgBox "Search completed."