简体   繁体   English

使用VBA,Access 2010将弹出式查询中的记录添加到主表单中的子表单

[英]Adding Records from a pop-up query to a subform within the main form using VBA, Access 2010

I have a main Purchase_Orders Form with an Items subform. 我有一个带有Items子窗体的主Purchase_Orders窗体。 I have also created a button that opens a popup form and queries previous Purchase orders for items that have been purchased from the same supplier which has been selected on the main form. 我还创建了一个按钮,该按钮打开一个弹出表单,并查询先前的采购订单,以查找从同一主表中选择的同一supplier购买的items I have added an unbound checkbox to this popup query. 我已向此弹出式查询添加了未绑定的复选框。

Now what I want to be able to do, is have an "assign" button that will select each record in the query where the checkbox = true (or 1 I'm not sure). 现在,我想要做的是有一个“分配”按钮,它将选择查询中的每个记录,其中复选框= true(或者我不确定1)。 And then input those records in to the main subform, Items . 然后将这些记录输入到主子窗体Items

Is this possible? 这可能吗? and any ideas how I may go about coding this in VBA? 还有关于如何在VBA中进行编码的想法? I am pretty new to VBA but if I get anywhere with the code, I will edit this post with further info. 我对VBA还是很陌生,但是如果我对代码有所了解,我将在本文中编辑更多信息。 Thanks! 谢谢!

If you want to add multiple items at once then you will need to use some form of unbound control, and a VBA loop to insert. 如果要一次添加多个项目,则将需要使用某种形式的未绑定控制和一个VBA循环来插入。

The simplest way would be to load a multi-select enabled ListBox and use that to allow the user to choose items. 最简单的方法是加载启用了多选功能的ListBox并使用它来允许用户选择项目。 Then upon clicking the Assign button, you can loop through the listbox and insert the items into the table. 然后,在单击“ Assign按钮时,您可以遍历列表框并将项目插入表中。

If you want more specific help you're going to need to provide much more specific data. 如果您需要更多具体的帮助,则需要提供更多具体的数据。 Table structures, form fields/data sources, form names, perhaps some VBA behind the forms. 表结构,表单字段/数据源,表单名称,也许在表单后面有一些VBA。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM