Access quits when binding a form to an ADO recordset using Jet in Access 2002 (288276)
The information in this article applies to:
This article was previously published under Q288276 Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
SYMPTOMS
When you open a form that is bound to an ActiveX Data Objects (ADO) recordset, you receive the following error message, and then Microsoft Access quits:
Microsoft Access has encountered a problem and needs to close. We are sorry for the inconvenience.
When you view the details in the error report, the report says that Microsoft Access caused an error in Msado15.dll.
CAUSE
This problem occurs under the following conditions:
- You have Microsoft Data Access Components (MDAC) 2.5 installed on your computer.
- You are binding the Recordset property of a form to an ADO recordset that is opened with the Microsoft Jet 4.0 OLE DB provider.
- The ADO recordset is using a server-side cursor.
- You are using the adCmdTableDirect option to open the ADO recordset.
RESOLUTION
There are two possible resolutions for this problem.
Use the Microsoft Access 10.0 OLE DB Service Provider
You can work around this problem by using the Microsoft Access 10.0 OLE DB service provider. Set the ActiveConnection property of the ADO recordset to an ADO connection that uses the Microsoft Access 10.0 OLE DB service provider along with the Microsoft Jet 4.0 OLE DB data provider. In Microsoft Access, the CurrentProject.AccessConnection property returns an ADO connection to the currently open database using the Microsoft Access 10.0 OLE DB service provider. For example, you can open the recordset by using code similar to the following:
Private Sub Form_Open(Cancel As Integer)
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = CurrentProject.AccessConnection
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = cn
.Source = "Customers"
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open Options:=adCmdTableDirect
End With
Set Me.Recordset = rs
End Sub
Use a Client-Side Cursor
You can work around this problem by using the Microsoft Jet 4.0 OLE DB provider, as long as you open the ADO recordset as a client-side cursor. To open the ADO recordset as a client-side cursor, set the CursorLocation property of the recordset to the adUseClient constant. For example, you can open the recordset by using code similar to the following:
Private Sub Form_Open(Cancel As Integer)
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = cn
.Source = "Customers"
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open Options:=adCmdTableDirect
End With
Set Me.Recordset = rs
End Sub
STATUSMicrosoft has confirmed that this is a problem in Microsoft Access. REFERENCES
For additional information about binding forms to ADO recordsets, click the following article number to view the article in the Microsoft Knowledge Base:
281998
How to bind Microsoft Access forms to ADO recordsets
For additional information about the difference between the Connection and the AccessConnection properties, click the following article number to view the article in the Microsoft Knowledge Base:
281784
Difference Between Connection and AccessConnection Properties
Modification Type: | Major | Last Reviewed: | 8/13/2004 |
---|
Keywords: | kbdta kbnofix KB288276 |
---|
|