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

Crystal Report 1

Status
Not open for further replies.

graphix03

Technical User
Oct 8, 2003
189
US
hi,

I need to put about 10 crystal reports
in to a visual basic app. the vb user
interface is already created and I can
list one report under the menu option.
I can also list the rest, but do i have to
list the directory for everyone report?
is there a better way to show the
report in vb?

I will post this in vb forum too, but
just in case you know anything about
this, plz advise. thanks so much.


Private Sub mnuReport1_Click()

Set mCrystal = New CRAXDRT.Application
Set mReport = mCrystal.OpenReport("C:\report1.rpt")

CRViewer1.ReportSource = mReport
CRViewer1.ViewReport

Set mCrystal = Nothing
Set mReport = Nothing

End Sub







 
This is really better suited for the Integrate forum (forum768). That being said, here's how I do it in a few of my apps:

At Design time:
1) Add three variables to a Code module:
Public crxApp As New CRAXDRT.Application
Public mReportPath As String
Public crxRpt As CRAXDRT.Report

2) Create a form with only a Crystal Report Viewer control (frmReport) with the code to set the Report object (to the filename in mReportPath), and send it to the Viewer.

3) On the application's main form, create a Reports menu with a submenu (mnuReportsList - which I give an Index of 0).

4) In the Click() event for the submenu, I call this:
[tt]
mReportPath = mnuReportsList(Index).Tag
frmReport.Show[/tt]


At Runtime:
I dynamically add reports to the submenu at runtime based on the contents of a Reports folder in the path of the application. As each filename is added to the menu, I set its Tag property to the full path to the report. If the Reports folder doesn't exist or is empty, I tell the user they've got no reports, and disable the Reports menu.

That's pretty much it. The most code involved is in dynamically adding the menu items.

-dave
 
Thanks very very much Dave, I've been looking all over for an answer on this, but most of the example I've seen is only show you how to list 1 reports, not 200 reports that I have to migrate from Access to VB. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top