MS Access:以编程方式复制/粘贴所选记录?

发布于 2024-08-30 13:23:16 字数 633 浏览 1 评论 0原文

抱歉冗长的介绍,但我认为最好解释一下我的问题的背景。我有一个 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 中以编程方式复制记录然后将其插入数据表中?感谢您的任何建议。

Sorry for the lengthy introduction but I think it best to explain the context of my question. I have an Access 2003 database in which users need to create new records based upon pre-existing records already in the table. Some of the users of the database are more familiar with computers in general and create a new record by ...

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

This works fine as the table the datasheet is based on uses an "auto-number" field preventing duplicates. The problem I am having is that some of the users of this database are not so "computer-savy" and are having some difficulty with right-clicking etc ... I have been asked to create a button that ..

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

The users can then edit the new record as needed. This leads me to my question. How do I go about copying a record and then inserting it into the datasheet programmatically in VBA? Thanks for any suggestions.

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

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

发布评论

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

评论(1

塔塔猫 2024-09-06 13:23:17

使用追加查询。

一些注意事项:

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

CurrentDb.Execute s

Forms!TableXForm.Requery

Use an Append query.

Some notes:

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

CurrentDb.Execute s

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