Printer 2 reports in one procedure.

superleo
superleo used Ask the Experts™
on
Dear all experts,

I would like to let user set the printer and print 2 reports when user press "Print" button.

The following is my code,

******************************************************
    If cbOT_Report.Value Then
      WriteTempOT
                 
      With crOT
        .ReportFileName = OTReport
        .ParameterFields(0) = ParaStr
        .Connect = ConnStr
        .SQLQuery = OTSQL
        .PrinterSelect
        .Destination = crptToPrinter

        .Action = 1
      End With
    End If
   
    If cbAllw_Report.Value Then
      WriteTempAllw
     
      With crAllw
        .ReportFileName = AllwReport
        .ParameterFields(0) = ParaStr
        .Connect = ConnStr
        .SQLQuery = AllwSQL
        .Destination = crptToPrinter
       
        .Action = 1
      End With
    End If
******************************************************

But is seem that just the first report will be printed.

Please to give me your kind advise.

Yours
superleo
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
What does cbAllw_Report.Value equal?
What does cbOT_Report.Value  equal?

Are you sure you are getting the first report and not the second or a somehow combined report?

Your code looks ok.  How are the various variables declared?  What do they equal?  

Any reason you didn't select the printer on the second report?  It may be going to the printer the report was built with.  Have you checked it?

mlmcc

Author

Commented:
Thanks mlmcc

In fact we need not to care the value of cbAllw_Report.Value and cbOT_Report.Value because I sure that it fulfill the condition and both program segment are ran.

Anyway, normally the user use the same printer to print both report so I just let them to select the printer once.

Please kindly to give me your advise again, thank you.

superleo
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
CR has a nasty habit of keeping the printer name with the report.  If the user cannot access the printer or doesn't have a default printer set, the report may not be getting printed.

mlmcc
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
What does AllwSQL equal?

How is crAllw declared and is it properly opened?

mlmcc

Author

Commented:
Hello mlmcc,

I have try to add one more .PrinterSelect but it prompt the select printer dialog box twice.

I can view the report properly when I preview the both report so I think that the SQL query has no problem.

Thank you for your help, mlmcc.

superleo

Author

Commented:
Hello mlmcc,

I have try to add one more .PrinterSelect but it prompt the select printer dialog box twice.

I can view the report properly when I preview the both report so I think that the SQL query has no problem.

Thank you for your help, mlmcc.

superleo

Author

Commented:
Hello mlmcc,

It is no problem when I preview on both report. So, I think that the SQL query has no problem as well.

Thank you very much, mlmcc

superleo
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
As I said in my first comment, the code you have posted looks fine.

I have asked clarifying questions because I have seen instances where adding the query or setting a parameter as you are doing causes a report not to work.  Without providing the requested information I cannot try to solve your problem.

Where does this code reside?  Which print button are you referring to?

If you reversed to order of the printint does the second report print?

mlmcc

This question has been classified abandoned. I will make a recommendation to the moderators on its resolution in a week or two. I appreciate any comments that would help me to make a recommendation.


Unless it is clear to me that the question has been answered I will recommend delete. It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.


If the user does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp

Pat K
EE Cleanup Volunteer

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: mlmcc {http:#7463546}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

mnye
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial