我正在尝试在上面的代码中执行更新语句,但是当执行DoCmd.RunSQL SQL3时,它会给出错误3265:此集合中找不到项目。来源:DAO.QueryDefs。 如果有人建议我在这里缺少什么,那就太好了。
SQL4 = "SELECT id from tblLastID"
Set temprsGenerateBilling = CurrentDb().OpenRecordset(SQL4)
bookingID = temprsGenerateBilling.Fields(0).Value + 1
SQL3 = "UPDATE tblLastID SET id=" & bookingID
DoCmd.RunSQL SQL3
答案 0 :(得分:0)
使用您已经打开的记录集:
SQL4 = "SELECT id from tblLastID"
Set temprsGenerateBilling = CurrentDb().OpenRecordset(SQL4)
If temprsGenerateBilling.RecordCount = 0 Then
temprsGenerateBilling.AddNew
Else
temprsGenerateBilling.Edit
End If
temprsGenerateBilling.Fields(0).Value = Nz(temprsGenerateBilling.Fields(0).Value, 0) + 1
temprsGenerateBilling.Update
temprsGenerateBilling.Close