Creating a Formatted Bound Report at Runtime
The following steps describe an alternative method of creating formatted bound reports:
- Create your Visual Basic application as in the first example above.
- Set the ActiveX Control to print to a preview window, and run the application.
- Click the Export button in the preview window, and export the report to a disk file in .RPT format.
- Once the report has been exported, you can open it up in Crystal Reports.
- Perform all formatting changes that you want and save the report.
- Return to the Visual Basic application and stop it if it is still running.
- On the ActiveX Control:
- Set the ReportSource to 0 - Report File.
- Set the ReportFileName to the .RPT file that you created.
- Run the Visual Basic application and you will be able to see your bound report with the formatting changes you've made.
Note:
- When creating formatted reports for use with the bound data control in Visual Basic, you will not be able to refresh the data from within Crystal Reports since the data does not exist outside of the Visual Basic application.
- If you plan on using a formatted bound report, you will not be able to modify anything in the SELECT statement of the data control. The report needs all these fields and will fail if they are not all there. The formatted report cannot report on any new fields.
When passing properties at runtime using bound reports (i.e., SortFields), the syntax is slightly different. For example, the following syntax would be used for the Formulas and SortFields properties in a normal report:
CrystalReport1.Formulas(0) = "COMMISSION= {TableName.FIELDNAME}"
CrystalReport1.SortFields(0) = "+{TableName.FIELDNAME}"
However, for a bound report, the following syntax would be used:
CrystalReport1.Formulas(0) = "COMMISSION= {Bound Control.FIELDNAME}"
CrystalReport1.SortFields(0) = "+{Bound Control.FIELDNAME}"