Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rptPrintSetup.Query (0) - on Cancel still prints

Status
Not open for further replies.

Boris10

IS-IT--Management
Jan 26, 2012
97
KE
Hi, i am building a crystal report and calling it using Accpac API. However, i would like to make it so that the user can select the printer as he/she prints.
Code:
Dim rpt As AccpacCOMAPI.AccpacReport
Set rpt = ReportSelect(report, "      ", "      ")
Dim rptPrintSetup As AccpacCOMAPI.AccpacPrintSetup
Set rptPrintSetup = GetPrintSetup("      ", "      ")
If rptPrintSetup.Destination = PD_PRINTER Then
    rptPrintSetup.Query (0)
End If
The above code works to get the printer selection window if print destination is set to printer. However, if the user presses "Cancel on the userform" the document is still printed.

How can this be avoided?
 
Do not set rptPrintSetup.Destination in your macro.
This way the user's printer destination setting in Accpac determines the print destination and all the logic flows from there, i.e. if the print destination is printer then the printer selection pops up.
 
Hi Ettienne, i have changed my code as per your suggestion. This is how it looks like now
Code:
Dim rpt As AccpacCOMAPI.AccpacReport
Set rpt = ReportSelect(report, "      ", "      ")
Dim rptPrintSetup As AccpacCOMAPI.AccpacPrintSetup
Set rptPrintSetup = GetPrintSetup("      ", "      ")
rpt.PrinterSetup rptPrintSetup
rpt.SetParam "@SELECTION_CRITERIA", val
rpt.NumOfCopies = 1
rpt.Destination = rptPrintSetup.Destination
If rpt.Destination = PD_PRINTER Then
    rptPrintSetup.Query (0)
End If
rpt.PrintDir = report
rpt.PrintReport

However, if the user chooses to print how does he select the printer. The only function that i have found that does this is
Code:
rptPrintSetup.Query (0)
. If i dont put this code, then the document is printed by a default printer. However, if i do put it even if the user cancels the printer selection window, the printer will still print.
How do i handle this scenario?

Thank you for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top