自动填充组合框

发布于 2024-07-22 17:16:03 字数 292 浏览 3 评论 0原文

我又来了。 我的表单上有 3 个组合框,即 cmbPart_number、cmbPart_name 和 cmbEOnumber。

我想知道的是,当用户从 cmbPart_number 中进行选择时,如何自动填充 cmbPart_name 和 cmbEO_number 框。 到目前为止,我所尝试的是在行源 SQL 查询中添加part_name和EO_number,并在 cmbpart_name 的控制源中添加 cmbpart_name(value)=cmbpart_number.column(1)

对此的任何帮助都非常感谢

Here i am again. I have 3 comboboxes on my form ie cmbPart_number, cmbPart_name and cmbEOnumber.

All i want to find out is how the cmbPart_name and cmbEO_number boxes are autopopulated when the user makes a selection from the cmbPart_number. What i have tried so far is adding part_name and EO_number in the row source SQL query and in the control source of cmbpart_name i have tried cmbpart_name(value)=cmbpart_number.column(1)

Any help with this is truly appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

似梦非梦 2024-07-29 17:16:03

您应该能够通过在 AfterUpdate 事件中设置 RowSource 来完成此操作

Private Sub cmbPart_number_AfterUpdate()

   cmbPart_name.RowSource = "...WHERE [PartNumber] = '" & _
                                                   cmbPart_number.value & "'; "
   cmbPart_name.Requery

End Sub

以下是 在Access中实现级联组合框

You should be able to do this by setting the RowSource in the AfterUpdate event

Private Sub cmbPart_number_AfterUpdate()

   cmbPart_name.RowSource = "...WHERE [PartNumber] = '" & _
                                                   cmbPart_number.value & "'; "
   cmbPart_name.Requery

End Sub

Here's a walk through on different ways to implement cascading combo boxes in Access

无人问我粥可暖 2024-07-29 17:16:03

我知道必须有一种简单的方法可以做到这一点,而无需深入研究 VB。 我的第一个组合框即 cmbPart_number,我已修改如下 - Row Source 在 SQL 查询中具有所有 3 个字段,即 SELECT part_number、part_name、EO_number from parts ORDER BY...;
我已将列计数修改为 2,因为 Access 始终将表中的第一列计数为数字 0。 所有 3 个字段均为 2。 我的列宽是 1";0"

接下来,我将 cmbPart_name 的控制源修改为 =cmbpart_number.column(1)。 它的行源有一个 SELECT 语句 SELECT part_number, part_name FROM parts, ORDER BY...
列数为 1,列宽为 0";1"

最后对于 cmbEO_number,控制源为 =cmbpart_number.column(2)。 行源选择语句为 SELECT part_number, EO_number FROM parts ORDER BY...列数为 1,列宽为 0";1"

现在,这可以正常工作,并且 cmbPart_number 框中选择的任何条目都会自动填充其他 2 个条目。
感谢大家的帮助。

I knew there had to be a simple way of doing this without digging deep into VB. My first combobox ie cmbPart_number, i have modified as follows - Row Source has all 3 fields in the SQL query ie SELECT part_number, part_name, EO_number from parts ORDER BY...;
I have modified the column count to 2 as Access always counts the first column in a table as number 0. So its Column 0,1 & 2 for all 3 fields. My column widths are 1";0"

Next I modified cmbPart_name's control source to read =cmbpart_number.column(1). Its row source has a SELECT statement SELECT part_number, part_name FROM parts, ORDER BY...
Column Count is 1 and Column Width is 0";1"

Finally for cmbEO_number, control source is =cmbpart_number.column(2). Row Source select statement is SELECT part_number, EO_number FROM parts ORDER BY...Column count is 1 and column width is 0";1"

This now works fine and any entry selected in the cmbPart_number box autopopulates the other 2.
Thank you all for your help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文