Solved Option to Filter by Cascading Combo Box Or Search by Text Box

Sarah.M

Member
Local time
Today, 20:14
Joined
Oct 28, 2021
Messages
335
Hi, Plz note, My VBA is blocked by IT for security reason.
I can use only Expression builder, Macros, Queries, Tables, Forms and Reports only.
------------------------------------------------
I have 3 combo boxes they are cascading each other by Query Criteria, But
In Combo box ComboN it has 2 Criteria for text box, becuse I want to have option to filter by combo box or by textbox, but it dose not work 😒

plz help me to fix it 🙏

Sample attached
1649073039229.png
 

Attachments

you cant put them all into 1 query, so instead, make the form show all records,
then FILTER the recs by inspecting the controls:


Code:
sub btnFind_click()
sWhere = "1=1"
if not isnull(cboState) then sWhere = sWhere & " and [state]='" & cboState & "'"
if not IsNull(txtName) then sWhere = sWhere & " and [Name]='" & txtName & "'"
if not IsNull(cboGender) then    sWhere = sWhere & " and [Gender]='" & cboGender & "'"

'then filer
if sWhere = "1=1" then
   me.filterOn = false
else
   me.filter = sWhere
   me.filterOn = true
endif
end sub
 
check and test.
see the macro on textbox TextSearch.
 

Attachments

check and test.
see the macro on textbox TextSearch.
I have a question out of curiosity, You use Macro "SetProperties Value" what is the main difference between SetValue and SetProperties Value?

1649143191781.png
 

Users who are viewing this thread

Back
Top Bottom