WinVask -  Faktura

Basics: Step 18 (Using Grand Total Fields)

Basics: Step 18 (Using Grand Total Fields)

Previous topic Next topic  

Basics: Step 18 (Using Grand Total Fields)

Previous topic Next topic  

 

The topics covered in pages 16 and 17 in the Tutorial help topics can also help you print a Grand Total on the last page of your report; just a matter of changing some settings for the variable.

 

ð        Add a new Report Band of the type Report Footer (click on BAND, then NEW, then Report Footer)
ð        Create a new frame inside this new report band; click on the Dictionary button
ð        Inside the Dictionary dialogue window left click the Grand Totals item; this is located under the Gather Totals section of the User Variables section.
ð        Click the '+' button to add a new variable
ð        Assign a UNIQUE name for this new variable; select the database field containing the dollar amount that you want added together. Change the picture length to a longer length than what the selected database field is already set to, and add the '$' character to the string. The "Total Type" will be "sum", and it will be evaluated 'At each record retrieve':

 

frb_bm117

 

After clicking the save button the dictionary screen is updated:

 

frb_bm118

 

Some sample output using the new Grand Total field on a report page:

 

frb_bm119

 

If you wanted to put forth the effort, you could define variables for each of the possible states that the database can have (50 states), then modify the Report Footer detail band to print a state by state breakout of sales. To perform this neat trick you would:

 

ð        Create a variable in the Dictionary for all 50 state abbreviation codes in the Grand Totals section of the dictionary. The variable would make use of 3 internal functions of the Report Builder: Clip(), Upper() and Choose(). The first two functions are used to convert the State database field into a consistent format for testing with the Choose() function. The Choose() function is used to compare the current database record against the known state abbreviation code; if it matches the database field containing the total sales for this customer living in the state is added to the variable (to keep a running total); otherwise it is skipped.
ð        In the Report Footer report band a new frame is added. The Dictionary button is clicked with the empty frame being highlighted. Under the Grand Totals section of the User Variables a new variable is created by clicking the '+' button.
ð        For this sample report a new variable is being created for state abbreviation code "FL" (all customers living in Florida). Here is what the variable information looks like:

 

frb_bm120

 

The Save button is clicked, which inserts the new variable into the selected frame:

 

frb_bm121

 

ð        Another trick being used is using the Center attribute for the frame contents for both the text string "Florida" and the Loc:Florida variable. By using the border attributes a table effect is achieved, which makes the summary page look very attractive.
ð        The pattern of adding a new frame for the state abbreviation code, and another frame for a new variable for that state abbreviation code is repeated. You can elect to stack them any way you desire; the choice is yours! Here is how the report band looks at the end:

 

frb_bm122

 

As shown above, 4 different states are being tracked, with the total dollar sales printed below. Here is the sample output:

 

frb_bm123

 

To recap: on this page you learned:

 

ð        How to use a Grand Total variable field on a report page
ð        How to use multiple Grand Total variable fields on a report page
ð        How to use frame borders to create attractive report output