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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get Crystal to select a different printer tray from Visual Basis

Printer tray selection

How do I get Crystal to select a different printer tray from Visual Basis

by  mikemer  Posted    (Edited  )
This is sample VB code. Modify it to suit your own needs


While Not rsSuppliers.EOF

DoEvents

With Mode

.dmDefaultSource = 1
.dmFields = &H200

End With

Response% = PEOpenEngine()

strSQL = ""
strSQL = "isnull({Beneficiaries.dt_Date_of_Update}) and isnull({Suppliers.dt_date_of_update}) and {Suppliers.c_Practice_Number} = '" & Trim(rsSuppliers!c_Practice_Number) & "' and {Member_Statement.c_Recipient_of_Payment} = 'S'"

Job% = PEOpenPrintJob("C:\Program Files\Seagate Software\Crystal Reports\Supplier Claims.rpt")

Response% = PESetSelectionFormula(Job%, strSQL)

Response% = PEOutputToPrinter(Job%, 1)

Response% = PEGetNPages(Job%) ' How many pages in report

Pages% = Response%

If Pages% <> 0 Then

Counter = Counter + 1

If Pages% = 1 Then

Mode.dmDefaultSource = 2 ' Lower tray

Response% = crPESelectPrinter(Job%, Printer.driverName, Printer.DeviceName, Printer.Port, Mode)

Response% = PEStartPrintJob(Job%, 1)

Else

Mode.dmDefaultSource = 1 ' Upper Tray

Response% = crPESelectPrinter(Job%, Printer.driverName, Printer.DeviceName, Printer.Port, Mode)

With Options

.collation = PE_UNCOLLATED
.nReportCopies = 1
.StructSize = PE_SIZEOF_PRINT_OPTIONS
.StartPageN = 1
.stopPageN = Pages% - 1

End With

Response% = PESetPrintOptions(Job%, Options)

Response% = PEStartPrintJob(Job%, 1)

Mode.dmDefaultSource = 2 ' Lower tray

Response% = crPESelectPrinter(Job%, Printer.driverName, Printer.DeviceName, Printer.Port, Mode)

With Options

.collation = PE_UNCOLLATED
.nReportCopies = 1
.StructSize = PE_SIZEOF_PRINT_OPTIONS
.StartPageN = Pages%
.stopPageN = Pages%

End With
This a sample of VB code that can be modified to suit your needs.

Response% = PESetPrintOptions(Job%, Options)

Response% = PEStartPrintJob(Job%, 1)

End If

Response% = PEClosePrintJob(Job%)

End If

rsSuppliers.MoveNext

Wend

rsSuppliers.Close
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top