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

HOW TO USE A CRYSTAL REPORT IN A VB6 APP 1

Status
Not open for further replies.

Hiccup

Programmer
Jan 15, 2003
266
US
Once the Crystal Report is created, which is tied to an Access2K database for it's recordset connection, how is it accessed within a VB6 app for printing?

I have a Command Button on the VB Form and would like to print the Crystal Report form when the Button is clicked.

Can anyone provide the code to accomplish this?

Thanks in advance!
 
Private Sub Command4_Click()
CrystalReport1.ReportFileName "c:/Masonic/rptperpetualmembers.rpt"
CrystalReport1.Action = 1

End Sub
This works for me, I hope it works for you. I have all the crystal reports in the Masonic folder.
 
There is an = between reportfilename and "c:
Private Sub Command4_Click()
CrystalReport1.ReportFileName = "c:/Masonic/rptperpetualmembers.rpt"
CrystalReport1.Action = 1

End Sub

don't know why it didn't post.
 
Thanks Billy71; here's a star for you. Is it the line:

CrystalReport1.Action = 1

that makes the report print?

Also, since I intend to pkg & deploy this app as a commercial application, would it be better to keep the Crystal Reports Files in the app's VB Folder along with the Access2K database?
 
The -1 will display the report then you can click the printer icon on the bottom of the displayed panel. You can also select the number of pages or print all.
 
I have the crystal reports in a folder with the vbsource code. I have the .exe files and .mdb in a separate folder but you could have it any way I guess. It seems to work either way.
Thanks for the star.
 
Sorry to keep loading this but one thing that got me in trouble. When you have the report open in Crystal reports and get ready to save it click on file and make sure "Save Data with Report is unchecked.". This messed me up a couple of times as it does just that and will not show new data in the database when it is updated.
 
Thanks billy71 for "Crystal Reports 101 Advanced." Here's another well-deserved star!!
 
Thanks again Billy71, but I'm getting a runtime error 424 "Object Required."

This is the code I used:

CrystalReport1.ReportFileName = "c:/EHicks/LOA EMAIL FOLDER/ClientsDatabaseReport.rpt"
CrystalReport1.Action = 1

I put my Crystal Report file, i.e., "ClientsDatabaseReport.rpt" in the same folder as my VB6 vbp and Access2K mdb files. In fact everything in my VB6 app is in the same file.

The line that's highlighted when I debug the runtime error is:

CrystalReport1.ReportFileName = "c:/EHicks/LOA EMAIL FOLDER/ClientsDatabaseReport.rpt"

However, I had forgotten to uncheck the "Save Data with Report." Do you think that might be the problem?

Another thought....I don't have Crystal Reports on my home PC where I experienced the error 424, but do on my work PC; I'll try your method when I get to my work PC. Does Crystal Report need to be installed on the PC when using your suggested method?

I know that Crystal Reports shipped with "pre-VB6" versions of VB and not VB6. Will this be a problem when I pkg & Deploy my VB6 app? I read somewhere that when you pkg & Deploy your VB app, you need to include any Access2K files and Crystal Report files you have for the app. If Crystal Reports is not part of VB6, how will Crystal Reports work in your deployed VB6 app?

Appreciate your thoughts!
 
> I'm getting a runtime error 424 "Object Required.

You need the crystal report dll file(s) on any machine that will run the report. Check your references and component lists to see which ones they are. Note: they must be registered on the client machine. You don't need crystal installed - just these runtime dll files.

Also, there might be some support dll files that are needed for Access or anything else, like ODBC, exporting, etc. You'll need to check the crystal developer help file for a list of files that need to be distributed. They should live in the same directory as the exe file or have the directory in the path environment (such as system32) or be in the startup directory for the exe in a shortcut. The easiest way is to keep them all together.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Also, you have the directory seperator wrong, the line ...

Code:
CrystalReport1.ReportFileName = "c:/EHicks/LOA EMAIL FOLDER/ClientsDatabaseReport.rpt"

...should read ...

Code:
CrystalReport1.ReportFileName = "c:\EHicks\LOA EMAIL FOLDER\ClientsDatabaseReport.rpt"

Regards,

Patrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top