查询无效 [英] Query not working

查看:67
本文介绍了查询无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨和新年快乐


我有一个QBF和一个很大的挑战。我似乎无法让它工作......


我有两张桌子:

联系

Contact_Type


我有一个表格:

Query_Window


在该表格中,最终用户应该能够勾选单选按钮(一个或多个 - 其中有16个) 和/或 使用一个文本框,在那里他们可以输入一个完整或部分单词(其中一个),还有几个单词最终用户选择的下方框(其中三个)。


我有查询:

qrySearchStatus


要测试表单,只要单击命令按钮,我就会选择几个单选按钮,状态和优先级?运行查询?一个窗口出现并说:

表格!Query_Window!TxtCompany
它为每个控件执行此操作,最后, 没有结果。无论我在表单上选择什么 - 即使它只是一个单选按钮,或在文本框中添加几个字母......


什么是我做错了?查询的SQL(qrySearchStatus)如下所示。我不知道该怎么做。


谢谢!!!


SELECT

Contacts.Company,

Contacts.State,

Contacts.Country,

Contacts.Priority,

Contact_Type.BD,

Contact_Type。 CO,

Contact_Type.CP,

Contact_Type.EN,

Contact_Type.FoF,

Contact_Type.FAM,

Contact_Type.FC,

Contact_Type.FO,

Contact_Type.GP,

Contact_Type.INS,

Contact_Type.IP,

Contact_Type.NHF,

Contact_Type.PB,

Contact_Type.SM,

Contact_Type.SWF,

Contact_Type.TH

FROM Contact_Type INNER JOIN联系人ON Contact_Type.ContactID = Contacts.ContactID


WHERE

(((Contacts.Company)喜欢" *"& [Forms]![Query_Window]![TxtCompany]&" * ")

AND

((Contacts.State)= [表格]![query_window]![cboState])

AND(( Contacts.Coun尝试)= [形式]![query_window]![cboCountry])

AND((Contacts.Priority)= [形式]![query_window]![cbPriority])

AND((IIf([forms]![Query_Window]![cb1],[BD] = True,True))= True)

AND((IIf([forms]![Query_Window] ![cb2],[CO] = True,True))= True)

AND((IIf([forms]![Query_Window]![cb3],[CP] = True,True) )= =真)

AND((IIf([forms]![Query_Window]![cb4],[EN] = True,True))= True)

AND ((IIf([forms]![Query_Window]![cb5],[FAM] = True,True))= True)

AND((IIf([forms]![Query_Window]![ cb6],[FC] =真,真))=真)

AND((IIf([forms]![Query_Window]![cb7],[FO] = True,True))=真)

AND((IIf([表格]![查询_窗口]![cb8],[FoF] =真,真))=真)

AND(( IIf([forms]![Query_Window]![cb9],[GP] = True,True))= True)

AND((IIf([forms]![Query_Window]![cb10] ,[INS] =真,真))=真)

AND((IIf([forms]![Query_Window]![cb11],[IP] = True,True))= True)

AND((IIf([forms]![Query_Window]![cb12],[NHF] = True,Tru e))=真)

AND((IIf([forms]![Query_Window]![cb13],[PB] = True,True))= True)

AND((IIf([forms]![Query_Window]![cb14],[SM] = True,True))= True)

AND((IIf([forms]![Query_Window] ![cb15],[SWF] =真,真))=真)

AND((IIf([forms]![Query_Window]![cb16],[TH] = True,True) )= =真))

OR(((Contacts.Company)为空)

AND((Contacts.Country)为空)

AND((Contacts.Priority)为空))

ORDER BY Contacts.Company;

解决方案

嗨Fspinelli,


当你说...


为了测试表格,我选择了几个单选按钮,状态和优先级,一旦我点击命令按钮运行查询,就会出现一个窗口并说:


表格!Query_Window!TxtCompany

这样做对于每个控件,最后,没有结果。无论我在表单上选择什么 - 即使它只是一个单选按钮,或在文本框中添加几个字母...



.. 。窗口是一个输入框,要求您输入数据?您的SQL显示对表单的引用,因此如果您运行查询,查询将查找需要编译的参数的表单。


如果您要添加窗体上的命令按钮,并将代码添加到命令按钮的OnClick事件中,该按钮表示...

展开 | 选择 | 换行 | 行号


< blockquote>不,它不是一个提示最终用户输入任何内容的查询。


这是一个可以做出选择并运行查询的表单。选项是单选按钮(其中16个)。可以勾选一个或多个。此表单上还有一个文本框,以防他们想要查询其中包含某些字母的公司。然后还有组合框。组合框将是州,国家和优先级。


如果最终用户勾选了几个单选按钮,那么所有带有这些选项的记录都会出现。如果最终用户只在文本框中输入几个字母,那么只会出现带有这些字母的公司。如果他们有那些单选按钮,带有字母AND的文本框他们从状态下拉框中选择NY,从优先级下拉框中选择1,那么这些记录只会出现。


最终用户不必选择其中一个或全部,他们可以选择查看NY中的公司或仅查看状态为FoF的公司,查询应该忽略空值(我在OR中有为空)查询栏的一部分)。


仍然无法正常工作 - 我还剩下半个头发...我正在使用你非常好的教程,但它并没有帮助我通过这个特殊的询问。


非常感谢,Beacon!


我当时没有谈论这个问题。你说当你点击Run时会弹出一个窗口,上面写着 Forms!Query_Window!TxtCompany ,对吗?弹出的窗口是否要求您输入任何内容或者看起来像错误窗口?


如果它是一个输入框,它将看起来是附件我''我在下面添加了。





附图像
untitled.bmp (104.4 KB,94 views)


Hi and Happy New Year!

I have a QBF and a big challenge. I can''t seem to get it to work...

I have two tables:
Contact
Contact_Type

I have a form:
Query_Window

On that form end users should be able to tick radio buttons (one or many - there are 16 of them) and/or use a text box where they can enter a full or partial word (one of these), and a few drop down boxes (three of these) that give the end user choices.

I have the query:
qrySearchStatus

To test the form, I chose a few radio buttons, a state and a priority, as soon as I click on the command button ?Run Query? a window comes up and says:

Forms!Query_Window!TxtCompany
And it does this for each control and finally, no results. No matter what I chose on the form - even if it''s just one radio button, or adding a few letters in the text box...

What am I doing wrong? The SQL to the query (qrySearchStatus) is below. I have no clue what to do.

Thank you!!!

SELECT
Contacts.Company,
Contacts.State,
Contacts.Country,
Contacts.Priority,
Contact_Type.BD,
Contact_Type.CO,
Contact_Type.CP,
Contact_Type.EN,
Contact_Type.FoF,
Contact_Type.FAM,
Contact_Type.FC,
Contact_Type.FO,
Contact_Type.GP,
Contact_Type.INS,
Contact_Type.IP,
Contact_Type.NHF,
Contact_Type.PB,
Contact_Type.SM,
Contact_Type.SWF,
Contact_Type.TH

FROM Contact_Type INNER JOIN Contacts ON Contact_Type.ContactID = Contacts.ContactID

WHERE

(((Contacts.Company) Like "*" & [Forms]![Query_Window]![TxtCompany] & "*")
AND
((Contacts.State)=[forms]![query_window]![cboState])
AND ((Contacts.Country)=[forms]![query_window]![cboCountry])
AND ((Contacts.Priority)=[forms]![query_window]![cbPriority])
AND ((IIf([forms]![Query_Window]![cb1],[BD]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb2],[CO]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb3],[CP]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb4],[EN]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb5],[FAM]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb6],[FC]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb7],[FO]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb8],[FoF]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb9],[GP]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb10],[INS]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb11],[IP]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb12],[NHF]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb13],[PB]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb14],[SM]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb15],[SWF]=True,True))=True)
AND ((IIf([forms]![Query_Window]![cb16],[TH]=True,True))=True))
OR (((Contacts.Company) Is Null)
AND ((Contacts.Country) Is Null)
AND ((Contacts.Priority) Is Null))
ORDER BY Contacts.Company;

解决方案

Hi Fspinelli,

When you say...

To test the form, I chose a few radio buttons, a state and a priority, as soon as I click on the command button “Run Query” a window comes up and says:

Forms!Query_Window!TxtCompany
And it does this for each control and finally, no results. No matter what I chose on the form - even if it''s just one radio button, or adding a few letters in the text box...

...is the window an input box asking you to type in data? Your SQL shows references to your form, so if you run the query, the query is going to look to the form for the parameters it needs to compile.

If you were to add a command button on the form and add code to the OnClick event for the command button that says...

Expand|Select|Wrap|Line Numbers


no, it''s not a query prompting for an end user to enter anything.

This is a form where they can make choices and run the query. The choices are radio buttons (16 of them). One or many could be ticked. Also on that form is a text box in case they want to query companies that have certain letters in them. Then there are also combo boxes. The combo boxes would be state, country and priority.

If the end user ticked a few radio buttons all records with those choices will come up. If the end user enters just a few letters in the text box, just companies with those letters would come up. If they had those radio buttons, the text box with letters AND they chose NY from the state drop down box, and 1 from the priority drop down box, then those records only should show up.

End user does not have to chose one or all, they could just choose to look at companies in NY or only those with a status of FoF, the query should ignore the null values (I have "is null" in the OR portion of the query column).

still not working - I have half a head of hair left...I am using your very nice tutorial, but it''s not helping me with this particular inquiry.

Thank you very much, Beacon!


I wasn''t talking about the query. You said that when you click Run, a window pops up that says Forms!Query_Window!TxtCompany, right? Is the window that pops up asking you to type anything into it or does it look like an error window?

If it''s an input box it will look the attachment I''ve added below.

Attached Images
untitled.bmp (104.4 KB, 94 views)


这篇关于查询无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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