我有這段代碼,我試圖在VBA中複製記錄。不幸的是我無法讓它工作。我不知道爲什麼它不會做任何事情。在VBA 2中複製記錄(新問題)
Dim OldRecord As DAO.Recordsets, NewRecord As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT [Tote Log].* FROM [Tote Log] WHERE Number = " & _
Me.tbScannerRead.Value
Set OldRecord = CurrentDb.OpenRecordset(strSQL)
If OldRecord.Count = 1 Then
Set NewRecord = _
CurrentDb.OpenRecordset("SELECT [Tote Log].* FROM [Tote Log]")
With NewRecord
.AddNew
For i = 0 To .Fields.Count - 1
.Fields(i).Value = OldRecord.Fields(i).Value
Next i
.Fields("Number").Value = Me.tbScannerRead & "B2"
.Update
varBookMark = .Bookmark
End With
NewRecord = varBookMark
DoCmd.RunCommand acCmdSelectRecord
Me.tbMessageBox = "Added new record"
Me.tbMessageBox.Visible = True
GoodToteRead = False
Me.tbScannerRead.SetFocus
End If
我什麼也沒得到,我試圖複製從手提包日誌記錄,並改變從數量,可以說,L20444到L20444B2並且具有相同的字段信息與原始。這是我迄今爲止的地方,但我什麼也得不到。 Ahy的幫助會很大,我的意思是非常感謝。謝謝