Solved

Printing Crystal Reports from VB

Posted on 2001-08-24
11
500 Views
Last Modified: 2007-11-27
I am using Crystal Reports in my VB program to provide reports.  Now, these reports need to be printed also.  If I just use the default print button that comes with Crystal Reports everything is fine.  The report gets printed in the format it is supposed to be on the default printer.

Recently I was asked to change the printing functionality to allow the users to select a printer other that the default printer.  I have tried to use the Printer dialog box in VB.  The first time the user selects a printer - any printer - the report prints fine.  If the user does not close the report (form) and wants to print againg, and selects a different printer the formatting of the report goes bad (really bad).  It appears that vb does not use the correct driver.  

I need to allow my users to select a printer other that the default printer.  Any suggestions?

Thanks!
0
Comment
Question by:moncsi
11 Comments
 
LVL 2

Accepted Solution

by:
daveherrmann earned 200 total points
ID: 6423352
Sure, dont use the print dialog in vb to select your printer.  I'm assuming your using the ocx to print the reports and your not using the api.

Right click on the ocx, click on the preview window tab and click on printer select.  This will add the printer setup button to the preview window.  If your doing it through the report designer, there is a similiar option (my machine is messed up or I would tell you where that is)
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 6423384
Can you provide the code you use to do the printing?

If you allow the users to preview the report you can add a printer selection button to the preview screen by setting

CR1.WindowShowPrintSetupBtn = True

thanks
mlm
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6424237
Learning...
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:moncsi
ID: 6429376
Guys,

I am using RDC.  I have tried several different ways of letting the user select the printer.

Right now all I have is sending parameter in for the report, showing the report, then printing the report by using the defult print button on Crystal.  When using the VB common dialog, I do get the correct printer, but the output sucks.  If I do not use the common dialog I can not change the printer.  RDC has a method called SelectPrinter (driver, name, port) when I tried to use this I got a message saying I do not have enough memory.

I wanted to try the WindowShowPrintSetupBtn  property, but I could not find that property anywhere.

Help!
0
 
LVL 2

Expert Comment

by:daveherrmann
ID: 6429400
try this
 CRPrinterSettings.PrinterSetup Me.hWnd

the full doc with an exampl can be found at
http://support.crystaldecisions.com/communityCS/FilesAndUpdates/printersettings.zip.asp?AJID=90FBBEF569D47A4A8EC1D52AD7C38FCD
0
 

Author Comment

by:moncsi
ID: 6429971
Thanks for the link.  It seems to have the same problem I do.  When I click on the Printer Setup Method to change the printer everything seems to be fine.  But when it prints it prints to the default printer no matter what was selected.  I think I am missing something!
0
 
LVL 2

Expert Comment

by:daveherrmann
ID: 6429973
can you post your code?
0
 
LVL 1

Expert Comment

by:ncw
ID: 6739526
I use crpReport.SelectPrinter (driver, name, port) and it works fine. My program allows the user to select a printer displayed in a listbox, the code iterates through the Printer collection setting the Printer object to the one matching the devicename the user selected, then I set:

crpReport.SelectPrinter Printer.DriverName, Printer.DeviceName, Printer.Port

Ok I have got 256K RAM but other machines it runs on have far less and they are ok.
0
 

Expert Comment

by:Jules_Madgwick
ID: 6961998
Using
CrystalReport1.PrinterSetup Me.hWnd
works fine !!!!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7202513
Hi moncsi,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept daveherrmann@idg's comment(s) as an answer.

moncsi, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: Please COMMENT.  I don't really know who deserves points here.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7216006
Per recommendation, force-accepted.

Netminder
CS Moderator
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question