Crystal reports processes different parts of the report in a fixed order that one must understand [to some degree] to understand what you can't do in Crystal.
- Pre-Pass #1
Before anything else, Crystal calculates "flat" formulas - those which require no database access. Some special fields (like print date) also fall into this category. At this time, Crystal also identifies parameter field contents and reads text objects. This is the Before Reading Records part of the process. - Pass #1
During this pass, Crystal reads records from the database. This is the While Reading Records period.- Retrieve Records - Crystal decides what fields to return from which database tables, generates SQL statements (or whatever is appropriate for the type of data upon which you are reporting) and retrieves data.
- Evaluate Recurring Formulas - These are formulas which contain database fields, but do not involve any summary data.
- Apply Record Selection Formula - Any summary or comparison processing is handled here, in order to eliminate rows returned from the data source.
- Group, Sort, and Total - Crystal now sorts records into groups, applies group selection formulas, and the like. This is also the pass in which summaries and totals are calculated. Formulas based on any of these types of information must be forced to calculate after this step.
- Generating Cross-Tabs - Enough said.
- Storing all Saved Records - All records and summary totals to be saved are now stored to temporary files. Until you change the report enough to change the SQL query, results can be pulled from these temporary files, which is much faster and uses no network traffic.
- Pre-Pass #2
The Group Sort Expert uses this time to perform hierarchical grouping operations. - Pass #2
This pass performs formatting and printing actions. This is the While Printing Records phase.- Reading Saved Records - Crystal reads saved records one at a time, along with subtotals, and evaluates them for display purposes.
- Applying Group Selection Formula - Group selection formulas are evaluated now because they rely on grouping and summarizing that occurs during Pass #1.
- Executing Running Totals - Running total fields generally depend on first-pass grouping and summarizing.
- Processing Print Time Formulas - Formulas which contain subtotals or summaries, or which include the WhilePrintingRecords function are evaluated here.
- Generating Charts and Maps
- Running Subreports - Subreports are not actually processed until the page upon which they appear is processed, or when the user clicks on them (in the case of on-demand subreports.)
- Generating Pages on Demand - Pages are not formatted until viewed or printed.
You can delay execution of formulas by using Evaluation Time Functions. This allows formulas to include elements that would normally be processed after they would - but in turn, they cannot be referenced by any formulas that occur later than the specified pass.
- BeforeReadingRecords - Specifies that formulas are run before the first pass.
- WhileReadingRecords - Specifies that the formula should run while reading database records.
- WhilePrintingRecords - Specifies that the formula will run while display formatting is occurring, after grouping, summarizing, and sorting have occurred.
- EvaluateAfter() - This will cause a formula to run after another [specified] formula has already been run. This is significant when two formulas in the same section must run in a specified sequence.