Crystal Reports in VB
Here is the easiest way I know:
1. Create your Crystal report and save it...you will need the full path and report name (example: X:\CrystalReports\MyReport.rpt ).
2. Create a New Standard EXE VB project and, in Project References, check the boxes for:
Crystal Report Viewer Control 9
Crystal Reports 9 ActiveX Designer Design and Runtime Library
Crystal Reports 9 ActiveX Designer Run Time Library
3. In Project Components, checkmark the box for Crystal Report Viewer Control 9.
4. Create two forms...name one frmMain and the other frmCrystal.
5. On frmMain, create a Command button for your report...double click it and put frmCrystal.Show as the code
6. On frmCrystal, double-click the CRViewer9 icon (on the General Toolbar) to put the viewer on the form (it will default name it CRViewer91 . You should set WindowState to Maximized.
7. Right-click on the form, click VIEW CODE and paste this code:
Private Sub Form_Load()
Dim Appl As New CRAXDRT.Application
Dim Report As New CRAXDRT.Report
CRViewer91.Top = 0
CRViewer91.Left = 0
CRViewer91.Height = 12336
CRViewer91.Width = 15408
Set Report = Appl.OpenReport("X:\CrystalReports\MyReport.rpt")
CRViewer91.ReportSource = Report
CRViewer91.ViewReport
End Sub
8. You can put a Command button on this form called Exit and paste Unload Me in it to return to frmMain.
9. This should do the trick...the great thing is you can edit the Crystal Report without opening VB and it does not overload the VB project with all your CR forms.
Run it and enjoy.
TomShark :D