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

Crystal Report Viewer

Status
Not open for further replies.

JDPurtell

Programmer
Aug 13, 2001
9
0
0
US
For simplicity sake I would like just one form in which I open up my crystal reports. Currently I am trying to use the crystal viewer. Well I can hard code one report name into the form_load procedure but when I try to manipulate with a variable to try and pass a differant report name it errors out. Has anyone solved this problem?? The documentation from seageate is not much help past the hard coding. Thanks
 
Your problem may be because your routine is in the form_load event. I've seen where references to certain objects (crystal viewer?) can cause an error in form_load, possibly because VB hasn't loaded the control into memory yet. You may try the form_activate routine, but be aware VB fires form_activate more than once during the scope a form (i.e. if a record is added to a database from a child DBGrid, hiding and showing the form, etc...) almost like the form_paint, so static a variable to keep track of wheather your code has already run for that instance of the form.

Hope that's it!

-Mike
Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
 
Previous month I finished with project CRviewer ( Crystal Report Viewer). It use Common Dialog Control for File opening, Crystal Report Print Engine -CRPE.dll, MDI form and Class Module for keeping in Registry List of most recent files. If You are interesting let me know.
 
JD,

do you want the clients to be able to actually select which report, as mikhailwaxman described, or to have a preset list of reports in the code so that when they push a button, a variable gets assigned that report name and thats teh one the crviewer opens. Thats how my crviewer app works, so let us know which is the way you want it to work.

Jack
 
I would be interested to see bpoth teqniques. I am currently using the preset list of reports I think. I have a deadlline in the morning so I hacked some code. It might have the same logic though. Thanks a ton.
 
JD, here's what I have done in a nutshell:
Main form has a toolbar with various buttons with the names of reports. As the user clicks on a button, a global variable is assigned the name of the report, sans the .rpt at the end. This is passed to the viewer, where I open the file by creating an instance of the CR application in code, passing it another global variable holding the path to the reports (we just have one static place for all), and the report name, where in the string I add the .rpt
i.e
Set Report = globalCrystalReportApplication.OpenReport(globalPath & globalCrystalReport & ".rpt")

From there we probably have similar code to generate the report and view it in the crviewer. Downside of this method: if you want to add reports, you have to hardcode it in, but if you're not planning on adding any, or you can set it up to dynamically create a drop down list with report names stored in a txt file or db, it'll work like a charm.

Hope that helped,
Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top