Microsoft KB Archive/257624

= How To Clear Report TAG, TAG2, and EXPR Fields Using .pjx Hooks =

Article ID: 257624

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q257624



SUMMARY
Microsoft Visual FoxPro developers sometimes want to distribute reports without the worry of possible differences between the printer information contained in the report and the printer on the system where the report is going to run. The example in this article uses the Visual FoxPro project hooks to reset printer-specific information within all the reports in a project.



MORE INFORMATION
When you save a report in Visual FoxPro, the printer driver information and other print options are stored in the report table. To avoid any discrepancies, clear the printer information stored in the report before you distribute the application. This information is stored in the TAG, TAG2, and EXPR fields of the report. If you clear these fields, Visual FoxPro uses the system default printer to output the report.

NOTE: The EXPR field also contains information about printer orientation, number of desired copies, and so forth. If your environment requires you to keep these settings, you should not clear this field. To do this, remark the line that reads: Expr with cEmptyStr Also, adjust the line previous to the EXPR field by removing the comma and semi-colon  to complete the REPLACE command.

If you do need to clear the values from the EXPR, you can store the information from the EXPR field into the USER Memo field, which has no effect on the report settings, and then replace it back to the EXPR when needed. Note this in the line of code: User with Expr,; &&Saves value of EXPR into USER Memo field The following code shows how to take advantage of Visual FoxPro project hooks to parse and reset the values of the TAG, TAG2, and EXPR fields on all reports contained in a specific project. The code assumes your reports are part of an existing project.
 * 1) Start Visual FoxPro.
 * 2) Create a new program (.prg).
 * 3) Paste the following code into the program and run it:

Local oFile, cEmptyStr, nReportCount nReportCount = 0 Clear Modi Project ? NoShow NoWait       &&Prompts the Project File name
 * 1) Define cEmptyStr Space(0)         &&Sets cEmptyStr value

For Each oFile In _Vfp.ActiveProject.Files
 * !* Loops into the Project Collection Object

If oFile.Type = 'R'                &&Checks for Report File Type Wait Window 'Clearing Fields in: ' +; oFile.Name TimeOut 1 Use (oFile.Name) Go Top Locate For ObjType = 1 and ObjCode = 53

If Found Replace Tag with cEmptyStr,; &&Clears the Tag, Tag2, Expr Fields Tag2 with cEmptyStr,; Expr with cEmptyStr  &&Remark this line to keep values in EXPR field nReportCount = nReportCount + 1 Use EndIf

EndIf

EndFor Wait Window AllTrim(Str(nReportCount)) +; ' Report(s) Modified in Project ' +; _Vfp.ActiveProject.Name
 * !* Displays Process Summary

