<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«


Previous pageReturn to chapter overviewNext page


Variables are temporary storage locations where you can save information that can be accessed at a later time.  Variables are useful for totaling field values across many records or within a group of records.  


Variables actually consist of several components.  Each variable must have a unique Name.  The variable name can be any combination of letters and numbers, but it is recommended that the variable's name describes the value it will hold.  For example, if we create a variable that will hold the total of all sales, we might name the variable "TotalSale".




The Reset At setting determines when the variable is reset to its initial value.  The variable can be reset at the report, section, page, or group header level.  When a variable is reset at the report level, the variable is initialized immediately prior to running the report and is not reset again until after the report has terminated.  Use the report reset level to create variables that sum values for the entire report.  


Variables that reset at the section level are initialized prior to the start of the section in which they are defined.  These variables are handy for creating totals for a section.  If a report has only one section, these variables behave the same as variables that reset at the report level.


When a variable is reset at the page level, the variable is initialized prior to the start of each page.  These variables are handy for creating page totals.  When a variable is reset at the group header level, it is initialized prior to the start of the group they are associated with.  Use the group header reset levels to create variables that total information with a group.


The value returned by the Initialization Expression is assigned to the variable immediately prior to running a report and again during the report depending on the Reset At setting.  This expression is used to "reset" the variable.  Variables that are used for calculating totals, counts, and averages normally have a Initialization Expression of: 0 (zero).


The Update At setting determines when the variable is assigned the value returned by its Update Expression.  A variable can be updated immediately before the page footer, body band (the default), or group footer prints.  The variable can also be set as a Constant.  When a variable is constant, its update expression is not used and it will retain the value assigned by its Initialization Expression throughout the report.


The Update Expression determines the value that is stored in the variable during the execution of the report.  If you define a variable that does not seem to contain the proper value, the Update Expression is the first place to look.


The position that variables are displayed in the Variables list determines the order in which the variable is updated relative to the other variables in the list. This position can be very important when variables reference other variables.  If the variable "TotalSale" references the variable "TotalTax" in its Update Expression, we must make sure that "TotalTax" is positioned above "TotalSale" so that "TotalTax" will contain a meaningful value when it is accessed.


Now that you know how to define a variable, how do you use it in a report?  This is the easy part.  When a variable name is referenced in an expression, the variable returns to the expression the value that it contains.  Simply put, once you have defined a variable, you can include it in an expression.




Notice that variables you define are available in the Variables list of the Expression Builder.  The variables can now be selected and placed on the report in the same manner as a database field.