SAP Knowledge Base Article - Public

1211588 - Create a manual running total in Crystal Reports using variables in Basic syntax

Symptom

This knowledge base article will explain the procedure of creating a manual running total in Crystal Reports using Basic Syntax.

Basic Syntax is similar to Visual Basic, except it has specific extensions to handle reporting. If you are familiar with Microsoft Visual Basic (VB) or other versions of Basic, then Basic syntax may be more familiar to you.

You would use Basic Syntax in the Crystal Reports Formula Editor where you have an option to write a formula using Crystal Syntax or Basic Syntax. For more information on Crystal Syntax and Basic syntax refer to the Crystal Reports User's Guide.

· How can you create a manual running total in Crystal Reports using Basic Syntax?

· How do you use variables in Basic Syntax to create a manual running total?

Resolution

Something to remember prior to creating a manual running total in the Crystal Reports Formula Editor using Basic Syntax is to use shared variables. Do not use Global or Local variables like you would when using Crystal Syntax.

The following is an example of how you would create a manual running total using Basic Syntax:

To launch the formula editor in Crystal Reports, complete the following:

1. From 'Insert', click 'Field Object'. This opens the Field Explorer.

2. Click 'Formula Fields', and click the 'New' icon.

3. Enter a name for the formula, then click 'OK'. For example, Rtotal1.

4. From the toolbar, select 'Basic Syntax' from the drop-down box. By default, 'Crystal Syntax' appears in the drop down box.

5. Create a formula similar to FORMULA 1 and save your new manual running total formula.

6. Repeat steps 1 to 5 to create all the formulas necessary to build the manual running total.

To use Basic Syntax to create a manual running total, create three formulas similar to the following:

FORMULA 1: @Rtotal1

'This formula initializes and resets

'(if necessary) the running total variable

Shared x as number

x = 0

formula = x

FORMULA 2: @Rtotal2

'This formula increments the running total variable.

Shared x as number

x = x + 1

formula = x

FORMULA 3: @Rtotal3

'This formula displays the final

'value of the running total variable.

Shared x as number

formula = x

TIP: =====

To create the second and third formulas without exiting the Formula Editor, click the 'New' icon on the Formula Editor tool bar (the icon of a sheet of paper)

========

From the field explorer, drag and drop each formula onto the report.

· Place {@Rtotal1} in the section where the variable is to initialize and reset, for example Group Header.

· Place {@Rtotal2} in the section where the variable is to increment, for example Details Section.

· Place {@Rtotal3} in the section where the variable is to display, for example Group Footer section.

NOTE: =====

If you are not familiar with VB or other versions of Basic, use Crystal syntax to create formulas, and/or read the chapter: "Creating Formulas with Basic Syntax' in the Crystal Reports User's Guide.

=========

Keywords

RUNNNING TOTAL BASIC SYNTAX FORMULA LANGUAGE MANUAL VARIABLE VARIABLES Seagate Crystal Reports Formula Editor Using Basic syntax to create manual running total formulas , c2006365 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To

Product

SAP Crystal Reports 8.0