Scottish_Anatomist
New member
- Local time
- Today, 19:38
- Joined
- Nov 18, 2015
- Messages
- 7
Hi Everyone,
I've created a search form where you can view multiple columns of data and can narrow down the data by searching via text box. I did this with the following code:
In the query for the list box the criteria applied to one of the fields is :
However, what i'd like to do is to be able to search by different fields (columns) by selecting the desired one in a combo box next to the search text box. So for example, if the listbox displays the company name, product and sales code, the combobox would have each of these as an option and then the text entered into the textbox would be applied as a criteria to that field in the query.
I originally tried to apply an IF statement to the criteria to check the value of the combobox, however then found out you can't use the Iif in that part of the query.
Any help would be greatly appreciated
I've created a search form where you can view multiple columns of data and can narrow down the data by searching via text box. I did this with the following code:
Code:
Private Sub txt_MarketSearchBox_Change()
Dim SearchString As String
SearchString = txt_MarketSearchBox.Text
txt_MarketSearchText.Value = SearchString
Me.lst_MarketSearch.Requery
In the query for the list box the criteria applied to one of the fields is :
Code:
Like "*" & [Forms]![frm_ProgrammeSearch]![txt_MarketSearchText] & "*"
However, what i'd like to do is to be able to search by different fields (columns) by selecting the desired one in a combo box next to the search text box. So for example, if the listbox displays the company name, product and sales code, the combobox would have each of these as an option and then the text entered into the textbox would be applied as a criteria to that field in the query.
I originally tried to apply an IF statement to the criteria to check the value of the combobox, however then found out you can't use the Iif in that part of the query.
Any help would be greatly appreciated