我可以添加“全部”吗?列表/组合框的选项,我该怎么做? [英] Can I add an "ALL" option to a list/combo box and how do I do it?

查看:63
本文介绍了我可以添加“全部”吗?列表/组合框的选项,我该怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


很抱歉,如果这个问题出现很多,我已经浏览了整个互联网,找不到一个有效的解决方案。


我想添加一个全部列表框的选项(和一个组合框,但我假设编码类似于我可以修改,如果需要),当选择并根据选择运行查询时,它返回与所有选项匹配的记录所述清单中的选项。我现在的代码是:

Hello all,

Sorry if this question appears a lot, I''ve looked all over the internet and can''t find a single solution that works.

I would like to add an "All" option to a list box (and a combo box, but I''m assuming the coding is similar enough for me to modify, if needed) that when selected and a query is run based off the selection it returns records that match all of the options in said list. The code I have right now is:

展开 | 选择 | Wrap | 行号

推荐答案

嗨。 UNION查询对于将< All>选项添加到listbox / combo是正确的,但这只是您需要做的第一部分。


然后你必须应用过滤器。为此,您需要使用列表框'After Update事件来响应用户的选择,并测试是否已选择''< All>'选项。如果有,你需要替换通配符(Access中的*)来匹配所有文本值:

Hi. The UNION query is correct for adding the ''<All>'' option to your listbox/combo, but this is only the first part of what you need to do.

You''ll then have to apply a filter. To do this you''ll need to use the listbox''s After Update event to respond to the user''s selection, and test whether or not the ''<All>'' option has been selected. If it has, you''ll need to substitute the wildcard character ("*" in Access) to match all text values:

展开 | 选择 | Wrap | 行号


感谢您的回复 - 我是否需要将通配符(*)写入列表框的行源的初始代码中?我尝试了你提供的代码但没有任何回报,我想它可能就在我的最后。有什么建议吗?
Thanks for the reply - Do I need to write the wildcard ("*") into the initial code for the row source for the listbox? I tried the code you provided but got nothing to return, and I think it might be on my end. Any suggestions?


你误解了列表框的作用 - 这是为了向你显示你的案例中的代表列表(联合了''All''选项),以及你是什么然后使用从列表框中选择的行的值来过滤表单。


正如您在第1篇文章中所说,您的列表框正在使用您的代表名称和所有选项正确填充。此后,您必须使用After Update事件来准备一个SQL语句,然后您可以根据从列表框中选择的值执行该语句以完成您想要完成的任何操作。


由于您还没有提供您尝试运行的查询示例,因此我可以对此进行更具体的说明,而不是告诉您步骤是什么,并指向您我最后一次链接的文章。


选择它后选择的值所做的并不意味着你改变了列表框的行源 - 只有在你进行级联过滤(过滤一个)时才需要这样做列表框取决于你从另一个人那里选择的内容)我怀疑这是你想要做的事情。


-Stewart
You are mistaking what the listbox does - which is to show you the list of reps in your case (with an ''All'' option unioned in), and what you do to filter the form afterwards using the value of the row selected from the listbox.

As you said in post #1, your listbox was being filled correctly with your rep names plus the All option. Thereafter, you have to make use of the After Update event to prepare an SQL statement which you can then execute to accomplish whatever it was you wanted to accomplish based on the value you have chosen from the listbox.

As you have not provided an example of the query you are trying to run I can be no more specific about this than to tell you what the steps are, and to point you back to the article I linked the last time.

What you do with the value you choose after you choose it should not mean that you change the row source for the listbox - this would only be necessary if you were cascade filtering (filtering one list box dependent on what you chose from another) and I doubt that this is what you are wanting to do.

-Stewart


这篇关于我可以添加“全部”吗?列表/组合框的选项,我该怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆