Conditional Printer Selection

  • Thread starter Thread starter Powderfinger
  • Start date Start date
P

Powderfinger

I have a report that I would like to print to the default printer if it is
less than 5 pages, or to a network printer if it is more than 5 pages (or so
many records in the record source).
Access 2003

Jack
 
Powderfinger said:
I have a report that I would like to print to the default printer if it is
less than 5 pages, or to a network printer if it is more than 5 pages (or
so
many records in the record source).
Access 2003

I think a solution here would be to simply "check" the results of the
reports query.


So, lets assume that the report is based on a query called

qryOverDueCustomers

The code to check how many records would thus be:

dim rstData as dao.RecordSet
dim strDefaultPrinter as string
set rstData = currentdb.OpenRecordSet("qryOverdueCustomers")
rstdata.MoveLast


if rstData.RecordCount > 100 then
' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName
' more then 5 pages, change pritner
Set Application.Printer = Application.Printers("HP LaserJet Series II")
docmd.OpenReport "rptOverdue"
'Swtich back.
Set Application.Printer = Application.Printers(strDefaultPrinter)
else
'print to default printer
docmd.openReport "rptOverDue"
end if
 
Thanks!

Albert D. Kallal said:
I think a solution here would be to simply "check" the results of the
reports query.


So, lets assume that the report is based on a query called

qryOverDueCustomers

The code to check how many records would thus be:

dim rstData as dao.RecordSet
dim strDefaultPrinter as string
set rstData = currentdb.OpenRecordSet("qryOverdueCustomers")
rstdata.MoveLast


if rstData.RecordCount > 100 then
' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName
' more then 5 pages, change pritner
Set Application.Printer = Application.Printers("HP LaserJet Series II")
docmd.OpenReport "rptOverdue"
'Swtich back.
Set Application.Printer = Application.Printers(strDefaultPrinter)
else
'print to default printer
docmd.openReport "rptOverDue"
end if
 
Back
Top