在多个搜索条件之间使用AND [英] Using AND between multiple search criteria

查看:69
本文介绍了在多个搜索条件之间使用AND的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的搜索表单存在问题我正在构建。我的搜索条件在文本搜索中没有问题。但我添加了几个数字搜索(cboSearchOrganization和cboSearchShopName)。似乎我对AND的使用/放置不正确。它告诉我语法无效。

展开 | 选择 | Wrap | 行号

解决方案

你说文本搜索工作,但我不太确定这个是这样的。您正在使用单独的IF语句来测试您的组合。假设目前只有第一个组合cboSearchLastName有一个值,所以满足第3行的IF并且不执行任何其他IF语句。在第14行的第一组SQL构建语句结束时,你在Where子句的末尾有一个悬空AND:

展开 | 选择 | Wrap | 行号

感谢您的回复。


我正在尝试构建一个搜索表单,根据搜索设置表单的记录源。有几个搜索条件。我有姓氏,名字,组织,商店名称,办公室符号等。我需要能够搜索一个或几个。所以姓氏,名字和组织。或者只是姓氏。


这就是为什么我在WHERE子句的末尾有AND。我正试图通过几个if语句进行搜索。我在想,也许我需要有sqlSearch = sqlSearch&在每个语句的开头?


我刚才意识到,我不认为recordsource可以是多个查询。似乎我可能必须将记录源作为我的主要查询(包含所有内容),然后根据搜索的内容对其进行过滤。听起来不错吗?


I have a problem with a search form I''m building. My search criteria works without a problem with text searches. But I added a couple numbers searches (cboSearchOrganization and cboSearchShopName). It seems my use/placement of AND is not correct. It is telling me invalid syntax.

Expand|Select|Wrap|Line Numbers

解决方案

You''ve said that the text searches work, but I''m not so sure that this is so. You are using separate IF statements to test your combos. Assume for the moment that just the first combo, cboSearchLastName, has a value, so the IF at line 3 is satisfied and none of the other IF statements is executed. By the end of the first set of SQL build statements at line 14 you have a dangling AND at the end of the Where clause:

Expand|Select|Wrap|Line Numbers


Thanks for your reply.

I''m trying to build a search form which sets the record source for the form based on the search. There are several search criteria. I have last name, first name, organization, shop name, office symbol, etc. I need to be able to search through one or several. So Last Name, First Name, and Organization. Or just last name.

That''s why I have AND at the end of the WHERE clause. I''m trying to get it to search through several if statements. I''m thinking, maybe I need to have sqlSearch = sqlSearch & at the beginning of each statement?


I just realized, I do not think the recordsource can be multiple queries. It seems perhaps I may have to have the recordsource be my main query (which contains everything), then filter it based on whats being searched for. Does that sound right?


这篇关于在多个搜索条件之间使用AND的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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