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



The information in this article applies to:

  • Microsoft Access 2002

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.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. In Microsoft Access, create a new project by clicking Project (Existing Data) in the Task pane.
  2. In the Data Link dialog box, select your SQL Server.
  3. Click Pubs for the Database to use on the server.
  4. Create a new report in Design view.
  5. View the report properties.
  6. Click the Event tab.
  7. 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 "SELECT * FROM authors", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
       Set Me.Recordset = rs
       Set Me.Recordset = rs
    
    End Sub
    					
  8. Place a Label control with data in the detail section of the report.
  9. Save the new report, and then close it.
  10. Preview the report.
  11. Close the report.
  12. Close the project.

    Note that when you close the project, you receive the error message that is mentioned in the "Symptoms" section of this article.

Modification Type:MajorLast Reviewed:9/26/2003
Keywords:kbbug kberrmsg kbnofix KB295191