VBA: Run-Time Error '3027' Using ODBCDirect to Open RecordSet (161252)
The information in this article applies to:
- Microsoft Visual Basic for Applications 5.0
- Microsoft Access 97
This article was previously published under Q161252 SYMPTOMS
Advanced: Requires expert coding, interoperability, and multiuser skills.
When you use an ODBCDirect connection to open a recordset, you may receive
the following error message if you use the .AddNew method:
Run-time Error '3027':
Can't update. Database or object is read-only.
This article assumes that you are familiar with Visual Basic for
Applications and with creating Microsoft Access applications using the
programming tools provided with Microsoft Access. For more information
about Visual Basic for Applications, please refer to the "Building
Applications with Microsoft Access 97" manual.
CAUSE
By default, Microsoft Access opens a read-only recordset in an ODBCDirect
workspace. The read-only recordset gives better performance when you scroll
through the recordset.
RESOLUTION
If you want to be able to modify a recordset in an ODBCDirect workspace,
you must specify a LockEdits argument with the OpenRecordset method. The
full syntax for the OpenRecordset method is:
Set recordset=object.OpenRecordset(source, type, options, lockedits)
You create an editable recordset when you use one of the following
constants in the LockEdits argument of the OpenRecordset method:
dbOptimistic, dbPessimistic, dbOptimisticValue, or dbOptimisticBatch
For example, the following sample code fragment opens an editable recordset
that uses optimistic record locking:
Set RS = conPubs.OpenRecordset("Authors",dbOpenDynamic,0,dbOptimistic)
NOTE: You must supply a zero (0) for the Options argument.
STATUS
This behavior is by design.
REFERENCES
For more information about ODBCDirect errors, please see the following
article in the Microsoft Knowledge Base:
169276 ACC97: OpenRecordset Method Options Incorrect for ODBCDirect
For more information about ODBCDirect workspaces, search the Help Index for
ODBCDirect workspaces or ask the Microsoft Access 97 Office Assistant.
For more information about using the OpenRecordset method, search the Help
Index for "OpenRecordset method."
Modification Type: | Major | Last Reviewed: | 10/29/2003 |
---|
Keywords: | kberrmsg kbprb kbusage KB161252 |
---|
|