FoxPro for Windows Report Writer Tips and Tricks

Last reviewed: June 4, 1996
Article ID: Q119156
The information in this article applies to:
  • Microsoft FoxPro for Windows, version 2.6

SUMMARY

This information is also available in FoxPro's online help system.

To go directly to this topic, do one of the following, depending on which online Help file is in use:

  • FOXHELP.HLP: Choose the "Tips and Tricks" help topic. Then, choose the "Report Tips" jump text.
  • FOXHELP.DBF: Choose the "Report Tips" help topic.

MORE INFORMATION

This topic contains a variety of Report Writer tips.

Run Existing Reports Without Changes

Your character reports (reports designed in FoxPro for MS-DOS) can be run, previewed and printed in FoxPro for Windows exactly as they were in MS-DOS, without any modification. If you want, you can transport your character mode reports into Windows to take advantage of the graphical environment by opening them in FoxPro for Windows.

Auto-Floating Fields

In FoxPro for MS-DOS, making fields stretch to accommodate data and float to maintain their relative position below other stretching fields are two separate operations. In FoxPro for Windows, fields automatically float when they are set to stretch. You can give a field the capability to stretch by choosing the Top -- Field Can Stretch radio button in the Position Relative To area of the Report Expression dialog.

Field Size

If you have a field that is smaller than the number of digits to be printed, FoxPro prints a series of asterisks to alert you that the complete number could not be printed. Fractions are rounded to fit the space you have allowed the field or expression. In FoxPro for Windows, changing the size of fields and graphic objects is as simple as clicking on an object handle (one of the small squares around the object when it is selected) and dragging.

Indicating Details "Continued" Over Page or Column Breaks

If you have stretching fields in a detail band, the detail band could extend over page or column breaks. You can include text to indicate when detail bands are continued on a new page or in a new column:

  1. Click on the text tool and type "continued" in the detail band.

  2. Double-click the "continued" text object to open the Text dialog.

  3. Choose the Print When... check box to open the Print When dialog.

  4. In the Print When dialog, choose No in the Print Once Per Band area.

  5. Choose the When Detail Overflows to New Page/Column check box.

  6. Choose OK until you are returned to the Report Layout window.

When the detail band is continued on another page or in another column, "continued" is printed. Otherwise, "continued" is not printed.

Using the Grid

When Snap to Grid on the Report menu is checked, objects are positioned according to an invisible alignment grid. You can change the size of this grid by changing the number in the horizontal (H) and vertical (V) spinners in the Grid area of the Ruler/Grid dialog (opened from the Report menu). The minimum grid size is one pixel and the maximum grid size is 48 pixels.

The alignment grid can be especially helpful in object arrangement because it is sensitive to object sizes and positions. Text objects to the left of a field, even if they are different sizes, are aligned with the field rather than with the grid. Fields placed on top of each other are aligned with no overlap and no intervening space.

If you want to override the grid setting when creating, moving or sizing individual objects or groups of objects, hold the CTRL key down and click on the object.

Fine-Tuning Object Position in Reports

Pressing an arrow key moves selected objects one pixel at a time, regardless of the setting of Snap to Grid. Holding SHIFT while pressing an arrow key resizes the selected object one pixel at a time, regardless of the setting of Snap to Grid.

Choosing Show Position from the Report menu displays the horizontal and vertical coordinates of the mouse pointer on the status bar when no objects are selected. When an object is selected, the top, left, bottom and right coordinates are displayed on the status bar, as well as the height and width of the object in the unit of measurement you have selected in the Ruler/Grid dialog. This information can help you to fine-tune the position of objects in your report.

Graphic Elements

Rectangles, rounded-rectangles and vertical lines can extend across several bands, for example, from the page header band to the page footer band or from a group header band to a group footer band. These graphic elements within a detail band can be made to stretch with the band by double- clicking on them and choosing Stretch with Band in the Rectangle/Line dialog.

Fonts in Page Preview

With some fonts, if you have a fairly small font size (8 or 10 point), you may not be able to see much difference between bold and regular type in the Page Preview dialog due to screen graphics. In the printed report, though, bold and regular type are clearly distinguished.

Remove Line If Blank

In FoxPro for MS-DOS, Suppress Blank Lines, once checked, applies to all objects in a report's detail band. In FoxPro for Windows, Remove Line If Blank performs the same function object by object in any band in the report. Remove Line If Blank must be checked for each object in a horizontal span across the detail band in order for blank lines to be removed.

Report Variables

Report variables allow you to do calculations that can be used in subsequent calculations. For example, if you wanted to make a time sheet report, if you have these numeric fields in a table (hour_in, min_in, hour_out, min_out), you could define a variable ARRIVE with the following expression:

   HOUR_IN + (MIN_IN / 60)

Another variable, LEAVE, would contain a similar expression:

   HOUR_OUT + (MIN_OUT / 60)

A third variable, DAYTOTAL, could hold the total amount of hours worked during the day. Assign it the following expression:

   LEAVE - ARRIVE

This third variable, could be used in a variety of other calculations to determine the number of hours worked in a week, a month, a year, the average number of hours worked each day, and so on.

Report Variable Hints

When setting up report variables, remember the following:

The order in which the variables are initialized is important. If var1 is used to define the value of var2, var1 must be precede var2 in the list in the Report Variables dialog so that var1 will be evaluated first. In the time sheet example, ARRIVE and LEAVE would have to precede DAYTOTAL in the list of variables.

When the variable is reset is important. By default, variables are reset at the end of the report. If your calculations are dependent upon data grouping, make sure that you select the proper group from the Reset popup.

Report variables can be used to calculate selected information from a table. For example, if you wanted to count all the companies in a certain state in your report (California in this example), you could create a variable with an expression similar to the following and then choose Sum in the Variable Definition dialog: IIF(state="CA",1,0)

Utilizing Page Space

Objects can be positioned partially underneath band separator bars to allow for maximum utilization of space on each page of your report.

Whole Page versus Printable Page

In the Page Layout dialog, you have the option to choose a print area of Printable Page or Whole Page. If you choose Printable Page, FoxPro sets the margins of the report according to the specifications of your default printer. Information will not be cut off along the edges of the page. A left margin of 0.0 causes text to print at the edge of the printable area on the page. Fields or text flush with the margins in the Report Layout window will not be cut off in the printed report.

If you expect your report to be run on a variety of printers, choosing Whole Page allows you to more closely control how the report will appear, no matter what printer is used. When you choose Whole Page, a left margin of 0.0 causes text to print right up to the edge of the paper. You may need to leave blank areas along margins in the Report Layout window so that a variety of printers will be able to print all the data in the report.

In either case, Page Preview displays the way a particular report would be printed on the current printer.

Summary Reports

In FoxPro for MS-DOS, you can save a report as a summary report. In FoxPro for Windows, you can print a report as a summary report by choosing More >> in the Report dialog and checking Summary Information Only, or by typing REPORT FORM <report name> TO PRINTER SUMMARY in the Command window and pressing Enter. (See the REPORT topic for other clauses that can be included with the command.)

Stretching Group Footers

In FoxPro for Windows, group footers can stretch to accommodate lengthy data. If a group footer will not fit completely on a page, it is printed in its entirety on the next page of the report. You need to make sure that your group footers aren't too long to fit on a single page.


Additional reference words: FoxWin 2.60 on-line
KBCategory: kbprg
KBSubcategory: FxprintFont


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 4, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.