You cannot add records or delete records with the ADO AddNew method or with the Delete method (289675)
The information in this article applies to:
- Microsoft Office Access 2003
- Microsoft Access 2002
This article was previously published under Q289675 Advanced: Requires expert coding, interoperability, and multiuser
skills. This article applies to a Microsoft Access database (.mdb) and to a
Microsoft Access project (.adp). For a Microsoft Access
2000 version of this article, see
225899. SYMPTOMS When you are using ActiveX Data Objects (ADO), if you use
the AddNew or Delete method of the Recordset object, and you open the recordset with an unspecified lock type,
you may receive one of the following error messages:
Run-time error '3251': Object or provider is not capable of performing
requested operation. Run-time error '3251': The operation
requested by the application is not supported by the provider. Run-time error '3251': Current
Recordset does not support updating. This may be a limitation of the provider,
or of the selected locktype. CAUSE By default, ADO recordsets are opened with a lock type of adLockReadOnly, which does not allow additions and deletions. RESOLUTION To allow additions and deletions, open the recordset with a
lock type of either adLockOptimistic or adLockPessimistic, as in the following code sample:
Sub DelFirstRec()
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "Select * from TestTable", CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic
rs.MoveFirst
rs.Delete
rs.Close
End Sub
NOTE: You can use this sample code to resolve the behavior in the
"Steps to Reproduce Behavior" section of this article.
Modification Type: | Minor | Last Reviewed: | 6/9/2004 |
---|
Keywords: | kbProgramming kbPerformance KbVBA kberrmsg kbprb KB289675 kbAudDeveloper |
---|
|