Microsoft KB Archive/295191

= ACC2002: Microsoft Access Quits If You Set the ADO Recordset Property Twice in the OnOpen Event of a Report =

Article ID: 295191

Article Last Modified on 9/26/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q295191



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access project (.adp).



SYMPTOMS
Microsoft Access allows you to set the Recordset property of a report to an ActiveX Data Objects (ADO) recordset. However if you set the Recordset property twice in the OnOpen event of a report that uses an ADO recordset, you receive the following error message when you close the application, and then Microsoft Access quits:

Microsoft Access has encountered a problem and needs to close. We are sorry for the inconvenience.



RESOLUTION
To resolve the issue, set the Recordset property only once in the OnOpen event of the report.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 In Microsoft Access, create a new project by clicking Project (Existing Data) in the Task pane. In the Data Link dialog box, select your SQL Server. Click Pubs for the Database to use on the server. Create a new report in Design view. View the report properties.</li> Click the Event tab.</li>  Click the Build (...) button, and then add the following code: Private Sub Report_Open(Cancel As Integer)

Dim rs As New ADODB.Recordset rs.Open &quot;SELECT * FROM authors&quot;, CurrentProject.Connection, adOpenKeyset, adLockOptimistic Set Me.Recordset = rs  Set Me.Recordset = rs

End Sub </li> Place a Label control with data in the detail section of the report.</li> Save the new report, and then close it.</li> Preview the report.</li> Close the report.</li> Close the project.

Note that when you close the project, you receive the error message that is mentioned in the &quot;Symptoms&quot; section of this article.</li></ol>

Additional query words: pra

Keywords: kberrmsg kbbug kbnofix KB295191

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.