Modify Report Layout

Important Note: It is very important that you backup your Reports before doing any modifications so you have a copy of the Reports before your modifications. This is so if you make a mistake and you cannot figure out how to fix it you can restore the Reports and start from scratch. It is also important to Backup your Reports once you have modified and tested to be sure your modifications work. If you save the Reports twice in one day you will need to rename the backup slightly so it does not overwrite your first backup as the default Report file name is MGMREPS20051220.zip (the 20051220 represents the date of 12/20/2005 and the system changes this daily).

One of the most powerful aspects of Masterpiece is the ability for you to customize the layouts (templates) for the various reports and labels.

Labels and Reports are very similar in how they function and how to modify them. We recommend you read the following topics in addition to this topic before doing any modifications. See the Modify Label Layout, Report Functions, Add Toolbars to Reports, Show Builds and Variables, and Envelope help topics for more information on modifying reports and labels.

Note: For help with setting page orientation and paper size, see the Envelope help topic.

These steps can also be used to customize labels. See the Modify Label Layout help topic for more information about labels and reports.

To begin the process, click on Tools, Modify Report Layout from the menu. You will not be able to preview the report as you are not in a data area. If you would like to preview as you customize you would need to go to Print and pick whichever report or label you want to customize so while in the report or label you can right-click on a blank area in the report or label and choose Preview from the pop-up menu.

A window will open showing all of the reports that are currently in your reports directory.

The Receipt report layout is the Template that controls the customer's receipt or invoice.

Double click on the report to open the report designer for the Receipt.

To see the entire layout, click the Maximize button.

Note that a VIEW option has been added to the menu.

This menu is used to turn several toolbars on and off.

Note that Format and Report options have also been added to the menu.

Use your mouse to turn on the Report Controls Toolbar, the Layout Toolbar, and the Color Palette Toolbar.

The Grid Lines and Show Position options are also useful features and should be turned on for this exercise.

Each Toolbar can be moved to a position on the screen that is most comfortable for you.

Report Controls Toolbar

You can create controls on your report or label with the Report Controls toolbar. Click the button for the control you want, position the mouse pointer on the report, and click the report to place the control or drag it to size.

On a report, you can double-click any control to display a dialog box for setting options.

This toolbar contains the following buttons.

Button Description

 

Select Objects

Resizes and moves Objects. After you create an object, the Select Objects button is automatically reselected, unless the Button Lock button is pressed down.

Label

Creates a label. Used for text that you don't want to change, such as a caption above check boxes or under a graphic.

Field

Creates a field box. Used to display the contents of a table's field, memory variable, or other expression.

Line

Use to draw a variety of line styles on your report at design time.

Rectangle

Use to draw rectangles on your report.

Rounded Rectangle

Use to draw rectangles with rounded corners and ellipse shapes on your report.

Picture/OLE Bound Control

Use to display a picture or contents of a general data field on your report.

Button Lock

Allows you to add multiple objects of the same type without having to click the button on the toolbar more than once.

In addition to the toolbar features, you will also want to know how to Move, Delete, and Resize objects. These features are discussed later in this section but you can jump directly to the help section by clicking on one of the following links:

Move

Delete

Resize

You will also need to understand the sections or Bands of the report.

Select Objects

Each object on a report can be selected individually by clicking on the object. You can select multiple objects to work on as a group in two ways.

  1. You can use your mouse to "draw a box" that touches or encloses all of the objects you want to manipulate.

  1. You can also select one object, and then hold down the Shift Key on your keyboard while selecting additional objects.

When you select an object, the object's borders will be shown and "little dots" will appear at the objects borders. These "dots" can be used to drag or resize the objects.

When an object is selected, you can change the attributes (size, font, color, etc.) for the object via the toolbars and menus.

Label

A Label object does not change as the data changes. In the receipt template, the word Date is a label. After selecting it, use the Format menu to change attributes, such as the Font.

Field

Field Objects are used to display information that changes based on the data for a report.

Each report has its own group of field names that are available to be printed. For a list of the available fields, see the help topic for the individual report.

To change a field object, use your mouse to double click on the object. This will open a Report Expression window. (Here, we have opened the report expression that has MailTitle in it.

Note that the expression is partly displayed. Click the edit button next to the Expression field to open the Expression Builder window and see more of the expression.

Field objects can contain functions A program call that automatically changes the input value to some other output value. as well as field variables.

Several report functions are discussed in the Report Functions help topic.

The object we have selected displays the client's Title, Firstname and Surname. Each of these pieces of information are stored in separate fields in the database.

This is a good example of how an expression is built, so we will discuss it in some detail.

In this example, the report field is called cuHeader.MailTitle. The "cuHeader" part of this field tells the report which table to get it's information from as the report is being created. Each report will have it's own table to draw data from. Generally you can find the name of the table simply by looking at the other fields in the template. If you are unsure of the table name, see the help topic for the appropriate report.

The cuHeader.MailTitle field stores the "Mr.", "Mrs.", "Dr." etc. But the actual field could have spaces on it as with "Mr. ", or "Mrs. ".

The second field is cuHeader.MailFirstName. If you scroll down you will also see cuHeader.MailLastName.

If the expression was entered as cuHeader.MailTitle + cuHeader.MailFirstName + cuHeader.MailLastName it might come out looking like

Mr. James Archer

because of the spaces in the field.

The "ALLTRIM()" function takes any leading or trailing spaces off of the expression. If the field were entered as:

ALLTRIM(cuHeader.MailTitle) + ALLTRIM(cuHeader.MailFirstName) + ALLTRIM(cuHeader.MailLastName)

the spaces would be removed and the output would look like:

Mr.JamesArcher

without any spaces at all....

To make the output look the way we want it to, we take out ALL of the spaces and then put back in just the spaces we want. To put a space where we want it, we enter the space in quotation marks. The expression then becomes:

ALLTRIM(cuHeader.MailTitle) + ' ' + ALLTRIM(cuHeader.MailFirstName) + ' ' + ALLTRIM(cuHeader.MailLastName)

Now, for a name that includes a title, firstname, and lastname, all is good. But if we have a name that does not include a title we would still have a space at the beginning of the printed line. So the output would not line up with the other lines of the report. To take care of this, we add one more "ALLTRIM()" function to the whole thing. The final expression becomes:

ALLTRIM(ALLTRIM(cuHeader.MailTitle) + ' ' + ALLTRIM(cuHeader.MailFirstName) + ' ' + ALLTRIM(cuHeader.MailLastName))

NOTE: When you use a function, the data that is being changed must be within the brackets () of the function. You have to be very careful to match the opening and closing brackets and place them in the correct positions. Failure to do this will cause a "Syntax Error" when you run the report.

Click the OK button to close the Expression builder window, then the Report Expression window and you should be back to the Report Designer window.

Let's walk through one more example on the Receipt report.

Double-click on the object that shows the page number.

Click the edit button next to the Expression field to open the Expression Builder window and see more of the expression.

In this example, there is a system variable called _pageno that is a numeric field for the page number. But on the report, we don't just want the number 1, 2, 3 or whatever. We want the report to print something like:

Page: 150

To do this, we work some magic. First, we want to always print the word Page, so we start the expression with

"Page:"

Note that the word MUST be in quotation marks (it doesn't matter if they are double or single quotes but you do have to use the same thing on both sides)

Next, we want the page number - but the page number is a NUMERIC value and "Page:" is a CHARACTER value. We are not allowed to mix numeric and character data in the same expression. So we use another Function A preprogram call that automatically changes the input value to some other output value. to change the numeric part to characters.

In this case, we use the STR() function. This function takes a number like 150 and changes it to " 150" but it has a problem. It puts spaces on the front of the character expression. To take off the spaces, we use the ALLTRIM() function we talked about above and insert our own space in the middle.

So then we have:

"Page:" + " " + ALLTRIM(STR(_pageno))

Moving Objects

There are two ways to move an object once it is selected. You can use your mouse to DRAG the object by positioning the mouse over the object, then holding down the left mouse button while dragging the object, and then releasing the mouse button when the object is where you want it.

For fine movements, you can also use the arrow keys on the keyboard to move the object up, down, left or right. Each time you press an arrow key, the object moves one pixel A pixel is a "dot" on your screen. If your screen resolution is 800 x 600 pixels, this means that the screen is 800 "dots" wide by 600 "dots" high. on the template.

Deleting Objects

Deleting an object is easy (TOO EASY??) You simply select the object and then press the Delete key on your keyboard. You can delete labels, lines, and fields very quickly and easily....

If you delete something you really didn't mean to, you have two options. You can exit the Report Designer, without saving changes, and start over. Or, you can use the menu to click the Undo feature. (This is the same as pressing CTRL-Z on your keyboard.)

Resizing Objects

How you resize an object depends on the object.

To resize a field object, you can use the mouse to click on the little "dot" and drag the edge of the object...

You can also resize the object by selecting the object and then using the arrow keys on your keyboard WHILE HOLDING DOWN THE SHIFT KEY.

Try it! Select one of the objects, then hold down the shift key and press the right arrow several times. You should see the object expand to the right.

You can also resize lines and rectangles in the same way.

 

Bands

Bands determine the various sections of the report. By default, the Report Designer displays three bands; Page Header, Detail, and Page Footer. A gray separator bar is located at the bottom of each band. The name of the band type appears on the bar next to a blue arrow, which indicates that the band is above, not below, the bar.

You can add the following bands to your report.

 

Band

Printed

Typical Contents

Column Header

Once per column

Column title

Column Footer

Once per column

Summary, totals

Group Header

Once per group

Preface to following data

Group Footer

Once per group

Calculated values for group data

Title

Once per report

Title

Summary

Once per report

Grand Totals

What this means is that, for the information you want to print at the top of each page, you enter the report fields ABOVE the Title band. For the information that is changing, you enter the report fields ABOVE the DETAIL band.

Ruler

The Report Designer has a vertical and horizontal ruler you use to more precisely position objects in the bands. Use the ruler in conjunction with the View menu's Show Position command to help you position objects.

The scale for the ruler is determined by your system measurement settings. You can change from the system default scale (inches or centimeters) to pixels from within Visual FoxPro. If you want to change to the system default, change the measurement setting for your operating system.

To change the ruler scale to pixels

Change this to pixels as follows:

  1. From the Format menu, choose Set Grid Scale. The Set Grid Scale dialog box is displayed.

  2. In the Set Grid Scale dialog box, select Pixels and choose OK.

The ruler scale is set to pixels, and the position indicator in the status bar (if Show Position is checked on the View menu) also displays positions in pixels.

 

Picture/OLE Bound Control

Adding a picture, like your LOGO to a report is easy.

Obviously, you have to create the logo and have it on your hard disk someplace to begin with. For this example, we are going to add our logo to the Receipt report.

We begin by making room on the report where we want to place the logo. In this case, we are going to use the top left section of the report. But we already have two fields that are taking up space where we want the logo go be placed.

Click on the Tax ID field and the press the delete key on the keyboard to delete it. (We don't really use that field in the United States anyway - if you're in Canada, or another country that requires a Tax ID move the field, MOVE the field instead of deleting it.)

Now use the instructions we talked about above under Move and Resize to move the SYSCOMPANY field out of the way. (SYSCOMPANY is your own company name for the report.)

Now we have room to put our logo !

You then select the OLE button to begin.

Your cursor will change to a hash mark. Use the mouse to draw a "box" where the logo should go.

After you draw the box, the Report Picture window will open.

Click the browse button next to File to locate your logo file. In this case we are selecting ArcherComTiny.jpg.

You can preview the picture file by selecting the Preview check box.

The one other IMPORTANT thing to do is to tell the system that you want to keep the logo in the same shape as it started. This is because it is unlikely that you drew a box with exactly the same proportions as your actual logo. Use the Scale Picture, retain shape option.

At this point your logo should come up on the form and can be moved or resized just like any other object.

 

Now, suppose you want to see what your reports look like with actual data, then modify them a little, then look at them again....

The system has a special feature, that you can turn on and off, that brings up the report designer automatically.

Check the Modify Reports option under the Print menu.

Now open up a form (like the transaction form) and set your parameters and then click the Preview button.

The Report Designer will automatically open.

Use the designer, like normal, to move or change the objects on the form.

To preview the actual form, with data, simply RIGHT-CLICK with your mouse on a blank white area of the form.

Then, left click on the Preview entry on the popup menu.