Solved

Printing Crystal Reports from VB

Posted on 2001-08-24
11
498 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now