Well, for Crystal, and anything that has a component that you can access through VBA, the basics are like this:
1 - Create a display.
2 - Put a button on it, right click button, select Property Panel, then under 'Expose to VBA', select "VBA Control.
3 - Right click it again, select "VBA Code"
4 - In the VBA Editor, go to Menu | Tools - References.
5 - Check off the following (if using Crystal):
Code:
Visual Basic for Applications
RSView Display Client Object Model
Microsoft Forms 2.0 Object Library
Microsoft ActiveX Data Objects 2.6 Library (or appropriate)
Microsoft OLE DB Service Component 1.0 Type Library (or appropriate)
Crystal Reports Report Viewer Control (I use vers 9)
Crystal Reports 9 ActiveX Designer Run Time Library (for dynamic forms and such if needed).
6 - For that display, in the upper left, right click "DisplayCode", and insert a new userform. Double click it to open it.
7 - Back to menu - View | Toolbox (These are Windows Forms controls)
8 - Back to the menu - Tools | Additional Controls - Check off Crystal Viewer 9 (in my case), and any others you might want. They will appear on the toolbox.
9 - Select the report viewer from the toolbox, and place one on the form. Size how you like.
10 - Play with some options on the properties box, name it "crViewer" so it works with the code below.
11 - Add a Windows button to populate your form, attach code similar to this:
Code:
Private Sub cmd_ShowReport_Click()
Dim crApplication As CRAXDRT.Application
Dim crReport As CRAXDRT.Report
On Error GoTo ErrHandler
'Create an instance of the RDC engine
Set crApplication = New CRAXDRT.Application
'Open the Formula Report
Set crReport = crApplication.OpenReport("MyReport.rpt", 1)
'Attach the Report Viewer control to the report to view
crViewer.ReportSource = crReport
'Set Selection Criteria for the Report
crReport.RecordSelectionFormula = "{tbl_Table.SelectionField} = 12345" ' Modify as needed or populate from form field.
'Display the report in the Viewer
crViewer.ViewReport
'Refresh the viewer to force update
crViewer1.Refresh
Exit Sub
ErrHandler:
LogDiagnosticsMessage Err.Number & " " & Err.Description & " in cmd_ShowReport_Click()", ftDiagSeverityInfo
End Sub
Those are the basics.