Creating a Formatted Bound Report
- Add the Data control, ActiveX control, and a command button to your form.
- On the Data control, set the DatabaseName property and the RecordSource property as you did in the previous example.
- On the ActiveX control:
- Set the DataSource property to the Data Control (i.e., Data1).
- Set the ReportSource property to 3 - All Data Control Fields.
- Open the Custom property and select the Data-Bound Report Tab.
- Click the Save Report As button and enter a name for the report.
- Open the report template in Crystal Reports and apply any formatting that you want including spacing between columns, font size, colors, grouping, and totaling. Save the report template again when finished.
- In your Visual Basic application, set the following properties for the ActiveX control:
- Set the ReportSource to 0 - Report File.
- Set the ReportFileName to the .RPT file that you saved (include the complete path of the file).
- On the command button, add the following code to the Click event:
Private Sub Command1_Click()
CrystalReport1.Action = 1
End Sub
Now, the application will create the report at runtime with the formatting you have applied.