如何在 Access 表单的组合框中使用通配符作为查询选项?
我正在 Access 中制作一个表单来搜索数据库。我希望能够使用组合框让用户知道数据库中存在的值。具体来说,类似于这个。 这工作得很好,但是,我还希望能够使用 "*"
通配符作为选项。在值列表中,它就像 "*";"value1";"value2";etc.
一样简单,但这在使用查询时似乎不起作用。
编辑:我发现这个。这似乎是解决问题的不同方法。我仍然愿意接受建议。
I'm making a form in Access to search a database. I want to be able to use a combo box to let the user know the values that exist in the database. Specifically, something like this.
This works perfectly, however, I'd also like to be able to use the "*"
wildcard as an option. In a Value List, it would be as simple as "*";"value1";"value2";etc.
but this doesn't seem to work when using a query.
EDIT: I found this. It seems like a different way of solving the problem. I'm still open for suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您的组合使用此 SELECT 语句作为行源。
如果除了唯一部门名称的行之外还需要包含“*”的行,则可以使用 UNION 查询。
您不需要 DISTINCT 关键字,因为 UNION 仅返回组合记录集中的唯一值。
您实际上不需要在第二个 SELECT 中为字段表达式 (
"*" AS dept_name
) 指定别名...只要数据类型与 dept_name 兼容,数据库引擎就会很高兴。我在第二个 SELECT 中选择了 SmallTable,因为您只需要一个具有单行的表(或查询或子查询)源。然而,超过一行不会成为交易杀手,因为 UNION 会丢弃重复项。
无论如何,这是我对您要寻找的内容的最佳猜测。如果我猜错了,请澄清你想要什么,一定会有人给你更好的答案。
Say your combo uses this SELECT statement as it's row source.
If you want a row with "*" in addition to rows for the unique department names, you can use a UNION query.
You don't need the DISTINCT keyword because UNION returns only the unique values from the combined record sets.
You don't actually need to alias the field expression (
"*" AS dept_name
) in the second SELECT ... the database engine will be happy as long as the data type is compatible with dept_name.I chose SmallTable in the second SELECT because you only need a table (or a query or subquery) source with a single row. More than one row will not be a deal-killer however, because UNION will discard duplicates.
Anyway that's my best guess as to what you're looking for. If I guessed wrong, clarify what you want and someone will surely give you a better answer.