1

对于冗长的介绍感到抱歉,但我认为最好解释一下我的问题的背景。我有一个 Access 2003 数据库,用户需要根据表中已有的记录创建新记录。数据库的一些用户通常更熟悉计算机,并通过...创建新记录

1. Selecting a previous record in a datasheet and copying it (via right click -> Copy)
2. Selecting new row in the datasheet and "pasting" the previous record (via right click => Paste)
3. Edit the newly pasted row with the new data

这很好用,因为数据表所基于的表使用“自动编号”字段来防止重复。我遇到的问题是该数据库的某些用户不是那么“精通计算机”并且在右键单击等方面遇到了一些困难......我被要求创建一个按钮......

1. Copies the previous record
2. Inserts it into datasheet

然后用户可以根据需要编辑新记录。这引出了我的问题。如何复制记录,然后在 VBA 中以编程方式将其插入数据表?感谢您的任何建议。

4

1 回答 1

1

使用追加查询。

一些注意事项:

s = "Insert Into TableX (Field1, Field2, Field3) " _
  & "Select Field1, Field2, Field3 From TableX " _
  & "Where ID=" & Forms!TableXForm!ID

CurrentDb.Execute s

Forms!TableXForm.Requery
于 2010-04-23T18:17:10.187 回答