Microsoft KB Archive/128879

= ACC: How to Print RecordSource Property Value for All Reports =

Article ID: 128879

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q128879



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



SUMMARY
This article shows you how to create a procedure that prints a list of each report in a database and its RecordSource property value to the Debug window (or Immediate window in version 2.0).

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.

NOTE: Visual Basic for Applications is called Access Basic in Microsoft Access version 2.0. For more information about Access Basic, please refer to the "Building Applications" manual.



MORE INFORMATION
The Reports collection is the set of all open reports. One method to print the RecordSource property value of each report is to go through the set of Report documents, open each one in Design view, and get the RecordSource property value. This article presents a procedure that uses that method. It automatically processes all the reports defined in the database. To create the procedure, follow these steps:

 Create a new module.  Type the following sample code:

In Microsoft Access 7.0 and 97: Sub ListReports Dim db As Database, doc As Document, con As Container Set db = CurrentDb Set con = db.Containers("Reports") Application.Echo False For Each doc In con.Documents Debug.Print "Report Name:", doc.Name DoCmd.OpenReport doc.Name, A_DESIGN Debug.Print "RecordSource:", Reports(doc.Name).RecordSource Debug.Print DoCmd.Close A_REPORT, doc.Name Next Application.Echo True End Sub

In Microsoft Access version 2.0:

Sub ListReports Dim db As Database, doc As Document, con As Container Set db = DBEngine.Workspaces(0).Databases(0) Set con = db.Containers("Reports") Application.Echo False For i = 0 To con.Documents.Count - 1 Set doc = con.Documents(i) Debug.Print "Report Name: " & doc.Name DoCmd OpenReport doc.Name, A_DESIGN Debug.Print "RecordSource: " & Reports(doc.Name).RecordSource Debug.Print DoCmd Close A_REPORT, doc.Name Next i        Application.Echo True End Sub  To see a list of reports and their RecordSource property values, type the following line in the Debug window (or Immediate window in version 2.0), and then press ENTER:

ListReports



Keywords: kbhowto kbprogramming KB128879

-

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

© Microsoft Corporation. All rights reserved.