[英]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.