Filter a Query based on 10 combo boxes but if comb

2020-05-11 01:42发布

问题:

I have list box pulls data from a query based on criteria's selected from Combo Boxes (the combo Boxes are filled whit Data from the same table every combo box from another column).

I use this code in query designer Like " * " & [Forms]![Costumers]![PB_City] & " * " in order to get partial

text from the table DB but it don't show a record if the field is blank.

The code Like " * " & [Forms]![AnyForm]![AnyThing] & " * " leave out the Blank records/

I wonder what's the exact syntax for the SQL or how to work in query designer where where clause in the SQL should only work if Combo Box Is not empty and should work only for this condition that means 1st Combo Box what filters 1st column only if its not ="" and all other Combo Box's , should filter their Columns , when 2nd Combo Box is empty it should if only for part of the SQL in where statement what work to filter the 2nd column based on 2nd Combo Box , And so on

When i tried to put this (OR [Forms]![myForm]![myControl] Is Null) After the like " * " & ..... Above if one combo box is empty no one of all other criteria's worked

回答1:

I found a code whats work type in query designer the following:


if you want to write in SQL take a look on this question,

Click on this link https://stackoverflow.com/a/38899574/9661307

or https://stackoverflow.com/a/38852152/9661307


in Query designer do the following

under your column you do the criteria

Like "*" & [Forms]![myForm]![myControl] & "*" OR [Forms]![myForm]![myControl] Is 
Null