How To Pass a Parameter Through a TierButton
Overview
This article explains how to run a report on one record or select a parameter on a document by passing the parameter for a Crystal Report through the TierButton.
Run a Report on One Record
Use this method to run a report on one record by passing the parameter for a Crystal Report through the TierButton.
General Process
- Create the Crystal Report with a parameter.
- Add a TierEdit and TierButton to the form.
- Create the FD table by saving the form as a document.
- Create a new report category if needed.
- Create the report.
- Set the Params property for the button.
Steps
Complete the following steps.
1. Form Controls
Place the following controls on the form.
| Control | Property on Object Inspector | Value |
|---|---|---|
| TierEdit | FieldName | test |
| Name | test | |
| Calculation | :tier_docid | |
| Fieldtype | integer | |
| Fieldsize | 0 | |
| TierButton | Params | Parameter name=:test |
| Action | baReport |
NOTE: For TierButton, In Design View on the Object Inspector, click the Params property. Click the ellipsis and add the parameter name=:control name here. The parameter name is the name of the parameter in Crystal Reports without the “?” preceding it. There are no spaces before or after the equal sign in Params.
2. FD table
Once the controls are on the form, save it as a document in a cabinet to create the FD table.
3. Report icon
- If needed, create a new report category by right-clicking the report icon and selecting New Report Category.
- Create a new report by right-clicking the report category and selecting New Report.
- Fill in name.
- Click on run Tool to open Crystal Reports.
4. Create report
- Insert the fields on the report.
- Create and insert the parameter.
- Select the parameter in Select expert.
- Save the report in the report directory on the server.
- Close the report.
- Click Browse to select the location of the report. The path will appear next to Report File.
5. TierButton
Connect the report to the button by setting the following property in Design View.
| Control | Property on Object Inspector | Value |
|---|---|---|
| TierButton | Report | The report name |
| Caption | Run Report |
NOTE: The report name refers to the name of the Crystal Report.
Select a Parameter on a Document
Use this method to pass only one parameter for a Crystal Report through the TierButton.
General Process
- Add a TierComboBox and TierButton to the form.
- Create the FD table by saving the form as a document.
- Create a new report category if needed.
- Create the report.
- Set the Params property for the button.
Steps
Complete the following steps.
1. Form controls
Place the following controls on the form.
| Control | Property on Object Inspector | Value |
|---|---|---|
| TierComboBox | FieldName | P_List |
| Items | List of the parameter defined in Crystal Reports | |
| TierButton | Params | Parameter name=:tiercombo |
| Action | baReport |
NOTE: For TierButton, the parameter name is the name of the parameter in Crystal Reports without the ? preceding it. For example, :tiercombo refers to the control name of the TierComboBox that has the parameter list. There are no spaces before or after the equal sign in Params.
2. FD table
Once the controls are on the form, save it as a document in a cabinet to create the FD table.
3. Report icon
- If needed, create a new report category by right-clicking the report icon and selecting New Report Category.
- Create a new report by right-clicking the report category and selecting New Report.
- Fill in name.
- Click on run Tool to open Crystal Reports.
4. Create report
- Insert the fields on the report.
- Create and insert the parameter.
- Select the parameter in Select expert.
- Save the report in the report directory on the server.
- Close the report.
- Click Browse to select the location of the report. The path will appear next to Report File.
5. TierButton
Connect the report to the button by setting the following property in Design View.
| Control | Property on Object Inspector | Value |
|---|---|---|
| TierButton | Report | The report name |
| Caption | Run Report |
NOTE: The report name refers to the name of the Crystal Report.
