简体   繁体   English

未输入参数的“输入参数值”提示

[英]“Enter Parameter Value” Prompt for Unreferenced Parameter

In MS Access 2007 I occasionally come across this issue: A query will start to produce a "Enter Parameter Value" prompt -- only the prompt is for a field that I do not reference in my SQL. 在MS Access 2007中,我偶尔会遇到此问题:查询将开始产生“输入参数值”提示-仅该提示适用于我在SQL中未引用的字段。

Example (query name: qryOPI_ReportingLocation ): 示例(查询名称: qryOPI_ReportingLocation ):

SELECT CODES.ReportingLocation, DateValue(OPI.EncDateTime) AS ApptDate, OPI.MedRec, OPI.AccessCode
FROM [OPI DATA] AS OPI LEFT JOIN [Access Codes] AS CODES ON OPI.AccessCode=CODES.Code
WHERE (IsNumeric(MedRec)) And (OPI.EncDateTime>=#10/1/2013#) AND (OPI.EncDateTime<#10/1/2014#);

Prompt: 提示:

输入参数值:qryOPI_ReportingLocation.EncDate

Why am I being asked for this parameter? 为什么要求我输入此参数? If I hit Cancel , the query fails to run. 如果我点击Cancel ,查询将无法运行。 If I enter any value (for example: bob ) the query will run correctly. 如果输入任何值(例如: bob ),查询将正确运行。

My Solution So Far: 到目前为止我的解决方案:

What's really frustrating, is if I take that same SQL, paste it into a newly created query it runs without a hitch. 真正令人沮丧的是,如果我使用相同的SQL,则将其粘贴到新创建的查询中,该查询可以顺利运行。 I then delete the old query and rename the new one until next time. 然后,我删除旧查询并重命名新查询,直到下一次。

Is there a better way? 有没有更好的办法?

Generally any time that I have run into this there is a remnant Order By field left in the query. 通常,每次遇到此问题时,查询中都会留下一个剩余的Order By字段。 Something that was set before and the SQL was changed but it stuck around. 之前设置的某些内容和SQL进行了更改,但仍然存在。

Put the query into SQL view, then on the right in the Property Sheet remove anything in the Order By property and the error should go away. 将查询放入SQL视图,然后在Property Sheet的右侧,删除Order By属性中的所有内容,错误应消失。

The second possibly is just a field name that has been misspelled, however since this looks like it was created using Query Design that is a little less likely. 第二个可能只是一个拼写错误的字段名称,但是由于它看起来像是使用Query Design创建的,因此可能性很小。

This is usually caused by misspelling a field name. 这通常是由拼写错误的字段名称引起的。 If you spell your field name even slightly different than it is spelled in the query or table definition, Access treats it as a parameter. 如果您拼写的字段名与查询或表定义中拼写的名字甚至略有不同,Access会将其视为参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM