简体   繁体   中英

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

Example (query name: 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. If I enter any value (for example: bob ) the query will run correctly.

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. 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. Something that was set before and the SQL was changed but it stuck around.

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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