![](/img/trans.png)
[英]How to Populate MS Access Main Form By Selecting Any Row from Sub Form
[英]How to copy data from a form+sub-form to table in ms access?
我創建了一個附加了子表單的表單。 我有一個運行查詢以刪除記錄的按鈕,但首先我想復制數據,包括所有子表單信息(如果可用於表)。 我使用了以下代碼,但沒有任何反應。 請! 我錯過了什么?
Private Sub Command63_Click()
Dim db As Database, delfile As Recordset, Criteria As String
Set db = CurrentDb
Set delfile = db.OpenRecordset("DelFile", DB_OPEN_DYNASET)
'add data to deleted taxpayer file table
With delfile
.AddNew
!DeletedBy = (Forms!MainMenu!username)
!Branch = Me.Branch
!TaxType = Me.TaxType
!Volume = Me.Volume
!Keyedby = Me.Keyedby
!DateKeyed = Me.DateKeyed
!CreatedAt = Me.CreatedAt
!Comment = Me.Comment
End With
delfile.Close
db.Close
End Sub
設置所有字段值后,您需要包含一個.update
以使更改.update
。 您的新代碼將如下所示。
Private Sub Command63_Click()
Dim db As Database, delfile As Recordset, Criteria As String
Set db = CurrentDb
Set delfile = db.OpenRecordset("DelFile", DB_OPEN_DYNASET)
'add data to deleted taxpayer file table
With delfile
.AddNew
!DeletedBy = (Forms!MainMenu!username)
!Branch = Me.Branch
!TaxType = Me.TaxType
!Volume = Me.Volume
!Keyedby = Me.Keyedby
!DateKeyed = Me.DateKeyed
!CreatedAt = Me.CreatedAt
!Comment = Me.Comment
.Update
End With
delfile.Close
db.Close
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.