ACC2000: Run-Time Error '3027' Using ODBCDirect to Open RecordSet (209943)
The information in this article applies to:
- Microsoft Visual Basic for Applications 6.0
- Microsoft Access 2000
This article was previously published under Q209943 Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies only to a Microsoft Access database (.mdb).
SYMPTOMS
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.
CAUSE
This behavior can occur because, 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 as follows:
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
dbOptimisticBatch
For example, the following line of sample code 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.
REFERENCESFor more information about ODBCDirect, click Microsoft Visual Basic Help on the Help menu, type differences between odbc drivers and built-in drivers for external data in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
For more information about the ODBCConnectStr property, click Microsoft Visual Basic Help on the Help menu, type odbcconnectstr property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Modification Type: | Minor | Last Reviewed: | 1/26/2005 |
---|
Keywords: | kberrmsg kbprb kbProgramming kbusage KB209943 |
---|
|