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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I call a rpoert on VB6? 1

Status
Not open for further replies.

Diginight

Programmer
Jan 28, 2005
5
US
Hi everyone, I’ve been using an old Crystal Reports program to design my report, like a pre 7.0 I guess possible 4.0 for that matter. Report consist of just listing information from an access 2002 database and the application that I made in VB6 was just a front end for the access database and a print button that on click will just display the report. The code looks like this as far as the print button goes

Private Sub Print_Click()
CrystalReport1.PrintReport
End Sub

And of course added the crystl32.ocx control component.

Now that I moved to CR10 dev ent. It’s a whole new world for me. First off I’ve read some of the forums on here and searched the internet on how to duplicate this process using CR10 but I have yet to figure out how. I seen many references to
VB6 samples : and
.Net samples : .

I downloaded the Simple Demo and upon loading in vb6 it tells me unable to load crviewer.dll. So what I did was go to references and selected
Crystal Reports ActiveX Designer Run Time Library 10 and then went to components and selected
Crystal ActiveX Report Viewer Library 10.0. I ran my application and it gave me this error,

Compile error: Method or data member not found

And it made a reference to:
CRViewer1.ReportSource = m_Report
and highlighted in blue ReportSrouce. What am I doing wrong??? I know I am overlooking something but I just can’t see it. For some reason I’m not getting the example in the simple demo zip file. Any help and or guidance will be appreciated.

Thanks

James
 
Make sure the only 2 Crystal references/components you have selected are:
1) Crystal Reports ActiveX Designer Run Time Library 10.0 (craxdrt.dll)
2) Crystal ActiveX Report Viewer Library 10.0 (CRViewer.dll).

In the 'old' days of the RDC, the default name for a Viewer component was 'CRViewer1' or 'CRViewer91'. Now it's 'CrystalActiveXReportViewer1'. Make sure your code references match the name of your component.

-dave
 
Thank you vidru!
Thanks for pointing that out for me. I'm somewhat of a newbie but I got a good starting point. So far this is what I have.

Private Sub Form_Load()
Dim App As New Application
Dim Rpt As Report
Set Rpt = App.OpenReport("f:\frontend\test.rpt")

CrystalActiveXReportViewer1.ReportSource = Rpt

CrystalActiveXReportViewer1.ViewReport

End Sub

So far works great! It displays my report just how I needed it to be. One question though, how do I tell it to just print the information without displaying the report to the user?

Thanks again.

James
 
Use the PrintOut method of the Report object:

Rpt.PrintOut ([PromptUser], [NumberOfCopies], [Collated], [StartPageNumber], _ [StopPageNumber]

So, if you want to print straight to the default printer, without prompting the user for what pages to print:

Rpt.PrintOut False

-dave
 
How would I use that in my current code?

Private Sub Form_Load()
Dim App As New Application
Dim Rpt As Report
Set Rpt = App.OpenReport("f:\frontend\test.rpt")

Rpt.PrintOut = False

End Sub

It sends my report to the printer with no problem. But where or how do I recode my app and place this

Rpt.PrintOut ([PromptUser], [NumberOfCopies], [Collated], [StartPageNumber], _ [StopPageNumber]

I think i'm doing something wrong because it highlights it in red and it says Syntax error.

Thanks James...
 
Code:
Private Sub Form_Load()
Dim crxApp As New Application
Dim crxRpt As Report
Set crxRpt = App.OpenReport("f:\frontend\test.rpt")

crxRpt.PrintOut False

End Sub
-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top