Solved Option to Filter by Cascading Combo Box Or Search by Text Box (1 Viewer)

Sarah.M

Member
Local time
Today, 09:28
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

  • ‏‏Cmbobox.accdb
    928 KB · Views: 185

Ranman256

Well-known member
Local time
Today, 02:28
Joined
Apr 9, 2015
Messages
4,339
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:28
Joined
May 7, 2009
Messages
19,226
check and test.
see the macro on textbox TextSearch.
 

Attachments

  • __Cmbobox.accdb
    1.3 MB · Views: 271

Sarah.M

Member
Local time
Today, 09:28
Joined
Oct 28, 2021
Messages
335
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

Top Bottom