CarysW
Complete Access Numpty
- Local time
- Today, 17:40
- Joined
- Jun 1, 2009
- Messages
- 213
I'm creating a user friendly search function for my DB. I have a form which shows the search results with a 'Search' button which brings up a small Search Box. My Search Box has a Combo box whicvh is populated from a list I have written, it includes Name, Account number, Town, Postcode. Account number, town and postcode all work fine when searching - my problem comes when I try to search for name as in my actual list of accounts there are 2 fields; 'Business Name' and 'Trading As'. I want my users to be able to search for both of these fields under the 'Name' option so as not to complicate things - is this something I can put into the code or do I need to change something on my Search Box or Table or the query that the Search form gets it's information from?
Below is the code that I've used(I found the search box idea as a template on the web and changed it accordingly).
Below is the code that I've used(I found the search box idea as a template on the web and changed it accordingly).
Code:
'Generate search criteria
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
'Filter frmSearchA based on search criteria
Form_frmSearchA.RecordSource = "select * from qrySearchF where " & GCriteria
Form_frmSearchA.Caption = "qrySearchF (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"