Filter a Query based on 10 combo boxes but if combo box is blank show All records including empty,

社会主义新天地 提交于 2019-12-31 07:41:06

问题


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 


来源:https://stackoverflow.com/questions/52726899/filter-a-query-based-on-10-combo-boxes-but-if-combo-box-is-blank-show-all-record

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!