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

How to call viewer/report from any of multiple forms?

Status
Not open for further replies.
Jun 4, 2004
19
US
Hi,

I'm just starting to program with VB, so this is a newbie question.

I'm building an application where I choose one of a number of reports, and the form for entering that report's parameters pops up, and then calls the viewer to display that report. The code one usually uses to display the report is something like this:

CRViewer91.ReportSource = Form2.rpt

In order to display a report generated from any one of a number of forms I imagine I need a public variable for a form, which I'll then use like this:

CRViewer91.ReportSource = CallingForm.rpt

How should I set this up in the different code modules? I tried "Dim CallingForm as Form" in each form's general declarations area, then "Set CallingForm = Screen.ActiveForm" in the Form_Load event for each parameter form, but it didn't work. I'm sure it's easy if you know what you're doing, or at least I hope so. :)

Thanks so much.


Robin

 
If you're using .dsr's, in a Module, create a Public variable:
Public crxRpt As CRAXDRT.Report

Create a form (frmReportViewer) with nothing but a CRViewer, with the follwing code in the Form_Load event:
CRViewer.ReportSource = crxRpt
CRViewer.ViewReport

For each of your forms, you presumably have a statement like the following in the General Declarations section:
Dim Report As New [NameOfYourDSR)

After you've set your parameters, etc.:
Set crxRpt = Report
Dim f As New frmReportViewer
f.Show

If you're not using .dsr's, the theory is the same, but the execution is different.

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top