Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

A.29 Tutorial A-2 Income Statement Template, Part 2

  1. Now that you’re familiar with the database and which tables we’ll be reporting from, let’s create the report. Open Crystal Reports and choose Blank Report.
  2. A new report opens and the Database Expert is displayed. Under the Create New Connection folder locate the Access/Excel (DAO) option and click it. This opens the Access/Excel (DAO) dialog box.
  3. For the Database Name, enter the path where you have the new Xtreme.mdb database file located. After entering the file path, click the Finish button to return to the Database Expert.
  4. The majority of the income statement is going to be based on formulas and you can’t create formulas until after the report wizard finishes. So you initially want to specify the tables to print from, but not the fields.
  5. Select the following tables for the report: Account, Account Class, Account Type and Journal Entry.
  6. Click on the Links tab and the default links should be correct. Check yours against the next figure to see if they match and correct them if necessary.


  1. Once the table links are correct, click the OK button to close the Database Expert. You are now in design mode with an empty report.
  2. Before working on the report, let’s set the record selection formula so that only the necessary records are displayed. There are three conditions that need to be accounted for:
  • Only display the revenue and expense accounts. Since this is an income statement, we don’t want any of the balance sheet related accounts used. The Xtreme.mdb database has Revenue accounts with an Account Type ID of 4 and Expense Accounts have an Account Type ID of 5.
  • Filter on a parameter that prompts the user for which year they want to print the income statement.
  • Only the transactions that occur during the normal course of the business year should be used. Year-end closing statements should be excluded. In the Xtreme.mdb database, closing statements are defined by a Journal Entry Type ID of 9.

We’re going to build the record selection formula that handles these conditions. But first, we need to create the parameter that prompts the user for which year they want to print.

  1. In the Field Explorer window, right-click on the Parameter Fields category and select New. This opens the Create New Parameter dialog box.
  2. Enter the parameter name Year To Print. Change the Type to Number. Click the OK button to save your changes.
  3. Create the record selection formula by selecting the menu options Report > Select Expert. This opens the Choose Field dialog box.
  4. Select the field Account.Account Type ID. This opens the Select Expert dialog box.
  5. For the Account Type ID selection criteria, select Is Any One Of.
  6. In the drop-down box to the right, choose the numbers 4 and 5. This selects revenue and expense accounts.
  7. Create a new criteria by clicking the New tab and choose the field Journal_Entry.Journal Entry Type ID.
  8. For the selection criteria choose Is Not Equal To. In the drop-down box to the right select the number 9. This excludes year-end closing entries.
  9. Click the New tab and choose the field Journal_Entry.Date.
  10. For the selection criteria choose Formula. Enter the following formula in the input area to the right.

Year({Journal_Entry.Date}) = {?Year To Print}

  1. These are the three formulas you need to filter the report data. To confirm that you entered them all correctly, click on the Show Formula button and you should see the following formula listed:

{Account.Account Type ID} in [5, 4] and
{Journal_Entry.Journal Entry Type ID} <> 9 and
Year({Journal_Entry.Date}) = {?Year To Print}

  1. Check your formula against this one and make sure everything matches. Once it is correct, click the OK button to save your changes.