Solved

Printing Crystal Reports from VB

Posted on 2001-08-24
11
504 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

685 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