Microsoft KB Archive/145816

= How to access a report's data environment while the report runs =

Article ID: 145816

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q145816



SUMMARY
This article explains how to access a report's data environment while the report is running. You can use this method in Visual FoxPro 9.0, or you can also use the new Report Listener and take advantage of Visual FoxPro 9.0's event driven printing.



MORE INFORMATION
When you create a report, an associated data environment (DE) is created. The data environment contains information about the tables, views and relations associated with the report.

The data environment is an object, and it is a container for a cursor and a relation object. You can gain access to the DE of a report while it is running, so you can manipulate the its properties and methods.

To gain access to the data environment, you need to be able to reference it as an object. Use the NAME clause on the REPORT FORM command to specify an object's variable name for the data environment as in this example: REPORT FORM Samples\Mainsamp\Reports\salessum NAME salessum PREVIEW ; NOWAIT ** In VFP 7.0, use this line of code: ** REPORT FORM HOME(2)+"tastrade\reports\salessum.frx" NAME salessum  PREVIEW ; ** NOWAIT ?salessum.Name          && Returns DataEnvironment ?salessum.Cursor1.Alias && Returns sales_summary For example, if you want to manually open the tables associated with a report, you can call the OpenTables method of the data environment. The following step-by-step procedure explains how.

Step-by-Step Procedure
 Create a new report. Add the Customer table, located in Samples\Data, to the data environment, and drag it onto the Detail band of the report to create a quick report. In the DE, set the AutoOpenTables property to false (.F.). Add a title band to the report, and place a field in the title band. In the field expression, type OpenAll to call a user-defined function.  Create a program file. Adjust the following code to your needs, and place it in the program file: REPORT FORM NAME TEST &&Names the data environment TEST

PROCEDURE openall IF      TEST.OpenTables      && Calls the OpenTables method of the DE   ENDIF RETURN ""  Save the program, and run it.</ol>

Additional query words: DE aselobj

Keywords: kbcode KB145816

-

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

© Microsoft Corporation. All rights reserved.