Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Refresh and Print An Existing Crystal Report from VB 2

Status
Not open for further replies.

JohnBates

MIS
Feb 27, 2000
1,995
US
Hi ,

I am a beginner with Crystal Reports (8). I have built a CR.

In this VB app, I want the user to be able to open/view the report, but have it automatically refresh from the datasource beforehand.


This works.. but has 2 problems :
1) The .Refresh gives an error and

2) the .PrintReport does not print - no error

You have to click the Refresh icon to force the report to refresh from current data - then it does.
Also you have to click the Printer icon to print the report.

Thanks for any suggestions, John

Dim CRapp As New Application
Dim CRrpt As Report

Private Sub cmdViewReport_Click()

Set CRrpt=CRapp.OpenReport"C:\MyCrystalReports\AreaCodes.rpt")

CRViewer1.ReportSource = CRrpt
CRViewer1.Refresh get error "Method 'Refresh' of object... failed"

CRViewer1.ViewReport
CRViewer1.PrintReport 'no error just doesnt print

End Sub
 
OK, I finally figured it out.

This is what I ended up with. Maybe it will help someone.

Set CRrpt = CRapp.OpenReport("C:\MyCrystalReports\Area Codes.rpt")

CRrpt.DiscardSavedData 'this forces a refresh upon open
CRViewer1.ReportSource = CRrpt
CRrpt.PrintOut 'This brings up the window for which pages to print, number of copies
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top