简体   繁体   English

为什么在运行 MS Access 查询时会收到“输入参数值”?

[英]Why am I getting “Enter Parameter Value” when running my MS Access query?

SELECT ID, 
       Name, 
       (SELECT CityName 
        FROM City 
        WHERE Employee.CityID = City.CityID) AS [City Name] 
FROM Employee 
WHERE [City Name] = "New York"

I'm about selecting all employees who come New York but whenever I run the query, I always get a “Enter Parameter Value” box.我打算选择所有来到纽约的员工,但每当我运行查询时,我总是得到一个“输入参数值”框。 How can I fix this?我怎样才能解决这个问题?

This is because Access does not allow you to use field aliases in the query - it does not recognize [City Name] as a valid field name.这是因为 Access 不允许您在查询中使用字段别名 - 它不会将 [城市名称] 识别为有效的字段名称。 Aliases are only used as field names in the result set.别名仅用作结果集中的字段名称。 Rather, you need to use the entire expression.相反,您需要使用整个表达式。

As such, this query would probably be more easily defined in Access as:因此,这个查询可能更容易在 Access 中定义为:

SELECT ID, 
       Name, 
       CityName AS [City Name]
FROM Employee INNER JOIN City
    ON Employee.CityID=City.CityID
WHERE CityName = "New York"

Also, 'Name' is a reserved word - using it as a field name is not suggested.此外,“名称”是保留字 - 不建议将其用作字段名称。

Another thing to check is on the Home tab if you have any manual sorts or filters active on the query results.另一件要检查的事情是在“主页”选项卡上,是否在查询结果上有任何手动排序或过滤器处于活动状态。 There is a button on that tab to remove sorting that you wont find on the dropdown menu for the field.该选项卡上有一个按钮可以删除您在该字段的下拉菜单中找不到的排序。

检查您是否没有向“默认值”字段添加查询。

尝试单引号而不是双引号。

Just found out regarding this error: "One of your parameter is invalid".刚刚发现这个错误:“你的一个参数无效”。

To fix this, I had to change my data type for customer ID from Large number to number as it does contain a few numbers only.为了解决这个问题,我必须将客户 ID 的数据类型从Large number更改为number因为它只包含几个数字。 This fixed my issue.这解决了我的问题。

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

相关问题 为什么运行MS Access查询时会出现“输入参数值”? - Why am I getting “Enter Parameter Value” when running my MS Access query? 运行访问查询时,为什么会出现“函数参数无效”和“输入参数值”? - Why am I getting “Invalid argument to function” and “Enter parameter value” when running my access query? 为什么在MS Access中运行更新查询时要求输入“输入参数值”? - Why am I asked for “Enter parameter value” when running update query in MS Access? 为什么我在我的 sql 代码中输入参数值 - Why am I getting enter parameter value in my sql code 为什么会出现“输入参数值”? - Why am I getting “Enter Parameter Value”? 为什么要求我输入参数值? MS Access SQL - Why am I being asked to enter a Parameter value? MS Access SQL MS Access-尝试连接3个表时获取“输入参数值” - MS Access - Getting “Enter parameter value” when trying to join 3 tables Access 2010为什么提示我输入参数值 - Access 2010 why am I being prompted to enter parameter value 为什么我无法从此SQL查询中获得任何结果(MS Access) - Why am I not getting any results from this SQL query (MS Access) 尝试使用CDate时,我在MS Access查询中收到一条错误消息,指出“溢出” - I am getting an error saying “Overflow” in MS Access query when I try to use CDate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM