Solved

Select a printer from crystal viewer

Posted on 2003-11-30
6
815 Views
Last Modified: 2007-12-19
I'm trying to make it possible to select a printer when you press the printer button when using crviewer.  I Used this  code from crystal decisions:
                   Private Sub CRViewer1_PrintButtonClicked(UseDefault As Boolean)

                    UseDefault = False
                    On Error GoTo Cancel:
                    CommonDialog1.CancelError = True
                    CommonDialog1.ShowPrinter
                    MyRep.PrintOut False  
                    Exit Sub
                    Cancel:
                    MsgBox "Printing cancelled"
                    Exit Sub
                    End Sub
Everything works fine until after I've select my printer and click print.  At this point i get the "Printing cancelled" message box and nothing works. Any help would be greatly appreciated.
0
Comment
Question by:asmit8
6 Comments
 

Author Comment

by:asmit8
ID: 9848682
Is there a reference or component i'm missing or something?
0
 
LVL 3

Assisted Solution

by:kathmacmahon
kathmacmahon earned 40 total points
ID: 9849978
I had written similar code that worked up until Windows 2000 was released.  I determined that no matter the orientation selected on the print dialog, crystal wouldn't catch it.  I don't know if that's still an issue but you should probably test that.  Your users may try to make changes to their printer settings in the common dialog that might not change the way the report prints.

I think what you need to do is change your MSGBox to output the error that is occuring, because it might not be Printing Cancelled.  I ran the same code in their sample project and it worked.

Ultimately, I ended up placing the viewer on a form and disabling most of the inherit toolbar items and creating one of my own that allows the user to select either 'print' or 'print setup'.  There's a sample below that shows all the various ways to affect printer settings.

http://support.crystaldecisions.com/communityCS/FilesAndUpdates/printersettings.zip.asp
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 40 total points
ID: 9850699
It may be this line that is causing the problem of getting the PRINT CANCELLED displayed.

     CommonDialog1.CancelError = True

mlmcc
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 13

Accepted Solution

by:
EwaldL earned 45 total points
ID: 9853071
currently i can't see the link between your common dialog and the report. try hardcoding the values first such as
crReport.SelectPrinter "drivername", "printername", "port"
from (http://support.crystaldecisions.com/library/kbase/articles/c2003560.asp)

if you are in cr 9, then also set the paper orientation
http://support.crystaldecisions.com/library/kbase/articles/c2012124.asp
0
 

Author Comment

by:asmit8
ID: 9864825
I figured it out...thanks for all your help!
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9871748
And the answer is?

mlmcc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

18 Experts available now in Live!

Get 1:1 Help Now