我有一个非常简单的代码,它在我的Access数据库中向表中添加了新记录。它工作了一段时间,但现在我在字符串" .AddNew"上得到3001错误。 我不知道是什么原因导致这个错误。有任何想法吗?
Sub testAddNew()
Dim db As DAO.Database
Dim rcs As DAO.Recordset, rcs2 As DAO.Recordset, rcsLength As Integer
Dim sqlQr As String
Set db = CurrentDb
Set rcs = db.OpenRecordset("Table1", dbOpenTable)
With rcs
.MoveFirst
.AddNew
![column1] = "test"
.Update
.Bookmark = .LastModified
End With
End Sub
答案 0 :(得分:0)
打开正确的记录集:
Set db = CurrentDb
Set rcs2 = db.OpenRecordset("Table1", dbOpenTable)
With rcs2
.AddNew
![column1].Value = "test"
.Update
.Bookmark = .LastModified
End With
或尝试使用查询:
Set rcs2 = db.OpenRecordset("Select Top 1 * From Table1")