Dabblernl
Dabblernl

Reputation: 16121

'No Current record' error on tbl.Update after tbl.AddNew

I have this simple code:

Set tbl=DB.OpenRecordset("TableName",dbOpenTable)
tbl.AddNew
tbl("SomeField")=strSomeValue
tbl.Update

On the Update statement a no current record error is thrown. I don't even understand how this can happen after the AddNew statement did not generate an error?!

Upvotes: 0

Views: 918

Answers (2)

Dabblernl
Dabblernl

Reputation: 16121

I can come to no other conclusion than that the table has become corrupt. I removed and rebuilt it and refilled it with data. The problem went away then (for now).

Upvotes: 0

Matt Donnan
Matt Donnan

Reputation: 5003

I appreciate this is a simple answer, but do you definately have write permissions for the table in question, or perhaps have the DB reference open as read-only? If either is true then Access can pass through the .Addnew but will fail at the point of commit (.Update) I only say this because your code seems to be fine. If not then you can always try throwing a .MoveFirst in after opening your recordset to see if that also gives an error.

Upvotes: 1

Related Questions