如何基于组合框选择打开表单。 [英] How to open form based on combo box selection.

查看:84
本文介绍了如何基于组合框选择打开表单。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为switchboard的表格。并且它有两个组合框:组织和员工姓名缩写(cboOrganization,cboStaff_init)。还有一个名为OK的搜索按钮。参见图片DB1


我想要做的是,基于我的员工姓名缩写的选择。组合框,当我点击确定时按钮,我希望打开多个项目表单(测试2),仅对应于员工姓名缩写。参见图片DB2和DB 1.


我在这个VBA代码中真的很新,请尽可能提供代码。



I have this form called "switchboard" and in it are two combo boxes: Organization and Staff Initials (cboOrganization, cboStaff_init). There is also a search button called "OK". See picture "DB1"

What I want to do is, based on the selection of my "Staff Initials" combo box, when I click the "OK" button, I want the Multiple Items Form (Test 2) to open that correspond only to that "Staff Initials". See Picture DB2 and DB 1.

I''m really new at this VBA code, please provide code if possible.

附加图片
(14.7 KB,784 views)
Attached Images
(14.7 KB, 784 views)

推荐答案

查看DoCmd.OpenForm并将其放入按钮的onclick事件中。
Look into DoCmd.OpenForm and put it in the onclick event of your button.


嗨raka,


我要走了假设你的领域在测试2中。员工姓名首字母的表格称为Staff_Init。如果它不同,你需要在代码中修改它。代码背后的想法是,您正在为表单创建一个过滤器,并在您从交换机打开表单时触发它。形成。你需要确保允许过滤器和允许过滤器。 测试2的属性。表单设置为是。


在交换机上的命令按钮的Click事件中表格,输入以下代码:

Hi raka,

I''m going to assume that your field in the "Test 2" form for staff initials is called Staff_Init. If it''s different, you''ll need to modify it in the code. The idea behind the code is that you are creating a filter for the form and triggering it when you open the form from the "switchboard" form. You''ll need to make sure that the "Allow Filters" property for the "Test 2" form is set to "Yes".

In the Click event for the command button on your "switchboard" form, enter the following code:

展开 | 选择 | Wrap | 行号


当我点击按钮时,它表示表格 ;测试2不存在或拼写错误。但是,这是表单的实际名称。知道会发生什么吗? snaff_init值来自表1.


请参阅下一篇文章中的附件。
When I click on the button it says that the form "TEST 2" does not exist or its misspelled. However that is the actual name of the form. Any idea what could be happening? The snaff_init values come from Table 1.

See attachment on next post.


这篇关于如何基于组合框选择打开表单。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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