加载具有依赖于另一个组合框的值的组合框。 [英] Loading a combobox with values that are dependant on another combobox.

查看:86
本文介绍了加载具有依赖于另一个组合框的值的组合框。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含2个组合框的表格。


第一个comboBox给我一个可供选择的客户列表。


我我希望第二个comboBox填充Departments的名称。我只希望列出的部门与第一个组合框中选择的客户匹配。


不幸的是,从中抽取表格的原始数据库(SQLServer)有一个大的客户表。它为每个客户提供CustomerID。表中有多个公司名称条目与不同部门相同。

HI I have a form with 2 comboBoxes.

The first comboBox gives me a list of customers to select from.

I would like to have the second comboBox populated with the names of Departments. I only want the departments listed that match the Customer selected in the first combobox.

Unfortunatly the original database that the tables were drawn from (SQLServer) has one big Customers Table. It has a CustomerID for every Customer. There are multiple ''Company Name'' entries that are the same in the table with different departments.

展开 | 选择 | 换行 | 行号

推荐答案

用以下代码替换你的行设置sDepartment:
Replace your line setting sDepartment with :
展开 | 选择 | Wrap | 行号


FYI你有[]围绕整个参考而不是单个参考元素([tblCustomers.Company Name] =)。 />
选择在传递给SQL的值周围没有引号('')(... =" &安培; Me.cboSelectCustomer.Value)。

最后的.Value是不必要的。
FYI You had [] around the whole reference rather than individual reference elements ([tblCustomers.Company Name] =).
The selection had no quotes ('') around the value as passed to SQL (...=" & Me.cboSelectCustomer.Value).
The .Value at the end was unnecessary.


HI NeoPa


谢谢再次为你的帮助。我完全按照你的方式尝试了,结果是在我从第一个ComboBox中选择了一个值并点击第二个ComboBox中的箭头后,我在屏幕上看到一个PopUp框,要求我

"输入参数值" ..." tblCustomers.Company Name"。


只是为了感兴趣,如果我在弹出框中输入客户名称,然后单击O.K.它会加载第二个组合框,其中包含所有可能的部门,而不仅仅是第一个组合中已选择的客户部门。


再次非常感谢您的协助。


问候

Mike
HI NeoPa

Thanks again for your help. I tried it exactly as you have it and what happens is that after I have selected a Value from the first ComboBox and go to click on the arrow in the second ComboBox I get a PopUp box on screen asking me to
"Enter Parameter Value"..."tblCustomers.Company Name".

Just for interest sake if I do enter a Customers Name in the pop up box and then click O.K. it loads the second combo box with All possible departments not just those from the Customer that has been selected in the first combo.

Again thanks so much for your assistance.

Regards
Mike


这篇关于加载具有依赖于另一个组合框的值的组合框。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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