First Guide to SQL Anywhere Studio
PART 2. Getting Results with SQL Anywhere Studio
CHAPTER 8. Creating Reports with InfoMaker
You can enhance reports in many ways. In this section you will:
Rearrange objects
Add a title and date
Add page numbers
Add a count of the total number of contacts
To rearrange objects, you will:
Put the job role into the group header and change its display font
Move the remaining columns to close the gap left by moving the column
This is what the workspace will look like when you have finished rearranging the objects.
About report bands The header band contains heading information and is located at the top of each page. The detail band contains the retrieved data. The summary band contains summary information that applies to the entire report and is located at the end of the report. The footer band contains information to be located at the bottom of every page, such as a page number. For groups, the group header band and group trailer band contain information for the group. |
Move the pointer to the gray bar entitled 1: Header group title until you see a double-pointed arrow.
Drag the band down about 4 to 6 grid dots.
(To drag, press and hold the left mouse button, move the mouse, then release the mouse button.)
Move the pointer to the title column and drag it into the band for the group header.
Put it near the bottom of the band as shown.
With the title column still selected, click B for bold and I for italic on the StyleBar.
This makes the job role (title) stand out in the report.
Select Design->Preview from the menu bar.
You see the report and its data.
Notice that the value of the title column appears only once for each group. This is because the title column is now located in the group header band.
Previewing is helpful for identifying problems. Notice that the header Job Role is still present even though there is no longer a column in the detail band. When you return to the workspace you will delete the text.
Click the Preview button to return to the workspace.
Click the text Job Role in the header field.
Press the delete key.
Drag the First Name and Last Name textboxes in the header band to the right to fill the empty space.
Drag the first_name and last_name columns in the detail band to the right to fill the empty space.
If when previewing your report, your phone and fax numbers do not have enough room to display, lengthen the fields now. Click on fax and move your cursor to the edge of the field until you see a double arrow. Drag the arrow until the box is large enough to hold the resulting data. Perform the same procedure on the phone field. You may have to move a few of the fields in order to make room to expand the phone and fax fields.
You will make one final visual improvement now by left aligning the text in the column headers.
Choose Edit->Select->Select Text from the menu bar.
This selects all the headers. It may be difficult to see that they are selected because the band is so narrow.
Click the left alignment button on the StyleBar.
If your headers are not already bold, click the Bold button.
All the headers become left aligned (and bold).
Select Design->Preview from the menu bar.
Click the Preview button to return to the workspace.
Now you will add a title and date to the header band. They will be at the top of each page.
Move the pointer to the gray bar marked Header and drag it down about 10 grid dots.
Choose Edit->Select->Select Text from the menu bar (or use lasso selection).
This selects all the headers.
Press the down arrow key to move all the headers down close to the gray band.
This leaves room for the title.
Click the Text button in the Objects dropdown toolbar in the PainterBar (or select Objects(Text. from the menu bar).
Move the point of the pointer above the First Name box and down one grid dot from the top of the page.
Click.
This positions the text box for the title.
Type My Contacts.
Select 14 from the font size dropdown listbox to make the title bigger.
Click the Today button in the Objects dropdown toolbar.
Move the point of the pointer to the upper-left corner.
Click.
This places a computed field in the report. The computed field is for today's date.
Select Design->Preview from the menu bar.
Your report now has a title and today's date.
Click the Preview button to return to the workspace.
Now you will put page numbers in the footer band.
Move the pointer to the gray bar marked Footer and drag it down about 4 grid dots.
If necessary, use the scrollbar to make room at the bottom of the design workspace.
This makes space for the page number, which will be another computed field.
Click the Page button in the Objects dropdown toolbar.
In the footer band, move the point of the pointer to the center and down 2 grid dots.
Click.
Select a different font size (10) from the style bar.
This places a computed field for page numbers.
Select Design->Preview from the menu bar.
Click the scrollbar until you move to the bottom of the page.
You now have a page number on your report.
Click the Preview button to return to the workspace.
Now you will add a count of the total number of contacts you have to the end of the report. You will put the information in the Summary band, which means it will print at the end of the report.
Like the date and page number, the count will be a computed field. Only this time, you will create it yourself using the Compute button.
Move the pointer to the gray strip marked Summary for the summary band and drag it down about 6 grid dots.
This makes space for the total number of contacts, which will be a computed field.
Click the Compute button in the Objects dropdown toolbar.
In the summary band, move the point of the pointer to the center and down 4 grid dots.
Click.
This sets the position for a computed field that you will use for the total number of contacts. The Computed Object property sheet displays.
In the Name box, type total_contacts.
Click the More button.
The Modify Expression dialog box displays.
In the Functions box, click count(#x for all).
Your dialog box should look like this. The placeholder for what to count is highlighted.
In the Columns box, click last_name.
This selects the last_name column to apply the count function to. You are going to count all the last names to find out how many contacts you have in the report.
Click Verify.
You should get the message box stating that your expression is valid.
Click OK to close the message box.
Click OK to complete the definition of the expression for the computed field.
Click OK to accept the name and expression and close the property sheet.
You return to the workspace. The computed field is in place.
Click the Text button in the Objects dropdown toolbar.
Position the pointer to the right of the computed field and click.
Type contacts in all.
Drag the text box to line it up with the computed field.
Select the computed field and the text using lasso selection.
On the StyleBar, select 10 for a font size and click I for italic and B for bold.
How to use lasso selection |
Select Design->Preview from the menu bar.
Press the page down key and use the scrollbar until you see the end of your report.
The summary band of your report now shows the total number of contacts in the report. The number you see may not be 61. The number depends on the contacts currently in your database.
Click the Preview button to return to the workspace.