Microsoft KB Archive/287437

= You may receive the &quot;Run-time error 2593&quot; error message when you set or you retrieve the Recordset property of a report in an Access database =

Article ID: 287437

Article Last Modified on 1/31/2007

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition
 * Microsoft Office Access 2003

-



This article was previously published under Q287437



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

This article applies only to a Microsoft Access database (.mdb).



SYMPTOMS
When you set or retrieve the Recordset property of a report in a Microsoft Access database (.mdb), you receive the following error message:

Run-time error '2593':

This feature is not available in an MDB.



CAUSE
Reports in a Microsoft Access database do not support the use of the Recordset property.



RESOLUTION
You can simulate binding a report to a DAO recordset object by setting the RecordSource property to the name of a table, a query, or an SQL SELECT statement. If you want to use the same source for the report as a DAO recordset that you have opened, set the RecordSource property of the report to the Name property of the DAO recordset. The following example shows you how to open a DAO recordset that is based on a query and how to set the RecordSource property of the report to the same source as the source of the recordset.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.  CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

 Open the sample database Northwind.mdb. Close the Main Switchboard form when it appears. On the View menu, point to Database Objects, and then click Reports. In the Database window, click the Alphabetical List of Products report, and then click Design. On the View menu, click Properties to display the property sheet.</li> On the Edit menu, click Select Report to verify that the property sheet being displayed is the one for the report.</li> Click the Data tab, and then clear the RecordSource property.</li> On the View menu, click Code to view the module of the form.</li>  Add the following code to the module: Private Sub Report_Open(Cancel As Integer) Dim db As DAO.Database Dim rs As DAO.Recordset Set db = CurrentDb 'Open a DAO recordset based on the Alphabetical List of Products query Set rs = db.OpenRecordset(&quot;Alphabetical List of Products&quot;, dbOpenDynaset) Me.RecordSource = rs.Name End Sub </li> On the File menu, click Close and Return to Microsoft Access.</li> On the File menu, click Save, and then close the report.</li> Open the Alphabetical List of Products report in print preview.</li></ol>

Note that the report is bound to data from the Alphabetical List of Products query, which was the source of the DAO recordset object.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in Microsoft Access.

<div class="moreinformation_section">

MORE INFORMATION
The Help topic for the Recordset property states that this property applies to reports. This is only true if the report is in a Microsoft Access project (.adp file), and you are binding the report to an ADO recordset or retrieving an ADO recordset from the report. The Recordset property does not apply to reports in a Microsoft Access database (.mdb file).

Steps to Reproduce the Behavior
<ol> CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

</li> Open the sample database Northwind.mdb.</li> Close the Main Switchboard form when it appears.</li> On the View menu, point to Database Objects, and then click Reports.</li> In the Database window, click the Alphabetical List of Products report, and then click Design.</li> On the View menu, click Properties to display the property sheet.</li> On the Edit menu, click Select Report to verify that the property sheet being displayed is the one for the report.</li> Click the Data tab, and then clear the RecordSource property.</li> <li>On the View menu, click Code to view the module of the form.</li> <li> Add the following code to the module: Private Sub Report_Open(Cancel As Integer) Dim db As DAO.Database Dim rs As DAO.Recordset Set db = CurrentDb Set rs = db.OpenRecordset(&quot;Alphabetical List of Products&quot;, dbOpenDynaset) Set Me.Recordset = rs End Sub </li> <li>On the File menu, click Close and Return to Microsoft Access.</li> <li>On the File menu, click Save, and then close the report.</li> <li>Open the Alphabetical List of Products report in print preview. Note that you receive the following error message:

Run-time error '2593':

This feature is not available in an MDB.

</li></ol>

Additional query words: pra recordset report mdb

Keywords: kbbug kberrmsg kbnofix KB287437

-

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

© Microsoft Corporation. All rights reserved.