将记录从一种形式复制到另一种形式

时间:2015-06-29 16:26:12

标签: access-vba

我有一张表格,上面有一份包含位置信息的记录列表。每个记录都以复选框开头。我希望用户能够通过单击复选框选择他们感兴趣的多个记录,然后单击底部的提交按钮,然后传递选择并将其作为新记录复制到另一个表单。我将如何在VBA中执行此操作?

首先,我的主表单的数据通过表格输入。我创建了一个新字段并将其指定为布尔数据类型,以在表单中的每条记录旁边显示一个复选框图标。默认情况下会检查所有内容,这是第一个问题。如何在默认情况下取消选中所有记录?

其次,假设我找出了复选框问题,我如何让Access通过编码提交按钮将所需记录拉入新表单?

1 个答案:

答案 0 :(得分:1)

If you include the checkbox as a boolean table field, you can update the records and then when the user clicks the command button, either pass the SQL clause "where fieldY =true" as a parameter like "DoCmd.OpenForm "SecondForm", acNormal, , , , , "where fieldY =true". Then in the form open event, use Me.OpenArgs to get the clause to filter the records.

Or just have the second form record source include the clause "where fieldY =true" so it always opens with just those records.