多参数查询;忽略空白&结果匹配输入的所有参数 [英] Multiple parameter query; ignore blanks & have results match all parameters entered

查看:86
本文介绍了多参数查询;忽略空白&结果匹配输入的所有参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Access 2007来设计一个允许用户搜索历史照片库存的数据库。目前我有一个表格,其中包括日期,ID,描述,项目,部门,单位,设施,功能,子功能,地区,区域办事处和州。我使用form方法查询,每个字段都有文本框或组合框。我希望用户能够输入他们想要搜索的字段并将其他人留空。我希望查询忽略左边的参数,然后显示与输入的所有参数匹配的结果。例如,我希望能够输入日期范围,项目名称和区域,并希望结果与所有三个条件匹配,而不是日期范围内的所有记录以及与项目关联的所有记录以及来自指定区域的所有记录。我认为这可能与使用AND和OR有关。如果有人有任何智慧的话,我将不胜感激。这就是我到目前为止所提出的:

I am using Access 2007 to design a database that will allow users to search an inventory of historical photographs. Currently I have a table with fields such as Date, ID, Description, Project, Division, Unit, Facility, Feature, Subfeature, Region, Area Office, and State. I am using a query by form method that have either text boxes or combo boxes for each of the fields. I want users to be able to enter in the fields that they want to search by and leave others blank. I want the query to disregard the parameters left blank and then display the results that match ALL the parameters entered. For example I want to be able to enter a date range, Project Name, and Region and want the results to match all three criteria not all the records within the date range plus all records associated with the project plus all records from the specified region. I think it may have something to do with the use of AND and OR. If anyone has any words of wisdom it would be greatly appreciated. This is what I have come up with so far:

展开 | 选择 | Wrap | 行号

推荐答案

尝试使用像你这样的查询中的LIKE和Nz函数,我只会拿你的第一个参数和例子的日期参数:
Try using LIKE and Nz function in your query like this, I''ll only take your first parameter and the date parameter for the example:
展开 | 选择 | Wrap | 行号


我使用了你给我的内容和此错误消息语法错误(缺少运算符)in查询表达式来了,它突出了LIKE。
I used what you gave me and this error message "Syntax error (missing operator) in query expression" came up and it highlighted LIKE.


我也试过
Also I tried
展开 | 选择 | Wrap | 行号


这篇关于多参数查询;忽略空白&结果匹配输入的所有参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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