ms-access:使用 vba 删除当前行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12406703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ms-access: delete current row with vba
提问by Sefran2
I have a mask tied to a query.
我有一个与查询相关的掩码。
This mask display the records in an access table (one record at a time), say A table.
此掩码显示访问表中的记录(一次一条记录),例如 A 表。
When the user clicks on a button, the record is copied in another table, say B, and it has to be deleted from the original table (A). Moreover the mask has to pass to the next or previous record, if any.
当用户点击一个按钮时,记录被复制到另一个表中,比如 B,它必须从原始表 (A) 中删除。此外,如果有的话,掩码必须传递到下一个或上一个记录。
The table B can't have a key field.
表 B 不能有键字段。
How could I achieve this via vba?
我怎么能通过 vba 实现这一点?
回答by KFleschner
Have your button copy, and then delete the record being displayed on the form on your button press.
复制按钮,然后删除按钮按下时表单上显示的记录。
Sub btnCopy()
Dim strSQL as string
strSQL = "INSERT INTO TableB SELECT fld1, fld2 FROM TableA WHERE fld1 = '" & txtFld1 & "'"
CurrentDb.Execute strSQL
strSQL = "DELETE FROM TableA WHERE fld1 = '" & txtFld1 & "'"
CurrentDb.Execute strSQL
End Sub