The following guide describes how to create a Crystal Report which will prompt for a FROM and TO date and then filter the report according to the dates selected. This can be helpful when you need to base a report on a different time period each time.
In this example we are using Crystal Reports 2008 (version 12), however the same process should work with other versions of the Crystal Reports application.
The database field containing the dates will be ‘Application_Received_Date’.
- Open the report in Crystal Reports
- Using the Field Explorer, right-click on ‘Parameter Fields’ and select ‘New’
- Under ‘Name’ enter DateFrom
- Under ‘Type’ select ‘Date’
- Under ‘Value Options’ –
- Under ‘Show on (Viewer) Panel’ change to ‘Do not show’
- Under ‘Prompt Text’ enter Please specify the START DATE
- Click ‘OK’ to save the changes
- Again, using the Field Explorer, right-click on ‘Parameter Fields’ and select ‘New’
- Under ‘Name’ enter DateTo
- Under ‘Type’ select ‘Date’
- Under ‘Value Options’ –
- Under ‘Show on (Viewer) Panel’ change to ‘Do not show’
- Under ‘Prompt Text’ enter Please specify the END DATE
- Click ‘OK’ to save the changes
- Open the ‘Report’ menu then select ‘Select Expert’ followed by ‘Record’
- If this is your first time using the Select Export for this report you will see the ‘Choose Field’ window. If this happens, select the field you are going to filter by and then click ‘OK’
- If you have already used the Select Export for this report, click on the ‘<New>’ tab. The ‘Choose Field’ window will open. Select the field you are going to filter by and click ‘OK’
- Using the drop down list, select ‘formula:’
- In the text box to the right enter in the following formula (replacing databaseTable.databaseField with your filter field)
-
{databaseTable.databaseField} =({?DateFrom} to {?DateTo})
- Click ‘OK’ to save the changes
- Your report is now ready to filter by a data prompt.
- When you refresh the report you will be prompted for the START DATE and END DATE. The selected dates will be used to filter the report.