根据10个组合框过滤查询,但如果组合框为空,则显示所有记录,包括空, [英] Filter a Query based on 10 combo boxes but if combo box is blank show All records including empty,

查看:156
本文介绍了根据10个组合框过滤查询,但如果组合框为空,则显示所有记录,包括空,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表框,它根据从组合框中选择的条件从查询中提取数据(组合框填充了来自同一表的数据,而每个组合框都来自另一列).

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).

我在查询设计器中使用此代码 Like " * " & [Forms]![Costumers]![PB_City] & " * "为了得到部分

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.

类似于" * " & [Forms]![AnyForm]![AnyThing] & " * "的代码省略了空白记录/

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

我想知道SQL的确切语法是什么,或者如何在查询设计器中工作,其中SQL where clause仅在组合框不为空时才起作用,并且仅在这种情况下才起作用,这意味着第一个组合框将过滤第一个仅当列不是="且所有其他组合框都应过滤它们的列时,当第二个组合框为空时,如果仅对SQL的一部分,则应该根据第二个组合框来过滤第二列, 等等

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

当我尝试将此(OR [Forms]![myForm]![myControl] Is Null) After the like " * " & .....放在上面时,如果一个组合框为空,则所有其他条件均不起作用

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

推荐答案

我在查询设计器中找到了以下代码的工作方式:

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

如果您想用SQL编写,请看一下这个问题,

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

点击此链接 https://stackoverflow.com/a/38899574/9661307

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 

这篇关于根据10个组合框过滤查询,但如果组合框为空,则显示所有记录,包括空,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆