ATTAC "On the Fly printing" prints only to default printer regardless of printer chosen in print dia

T

tjacobi

Our application has used this PrintersClass module for some time without a
problem but some new Toughbooks have issues. We use laser printers, usually
the default choice, and some label printers. The label printers use the
Seagull Scientific print drivers. The new notebooks do not print
consistently to the selected label printers. The default printer for the
report is a label printer and it comes up in the dialog box as the selected
printer initially. Even if you redundantly select this label printer again,
before selecting print, you get the label printed to the users default
printer instead of the selected label printer. The drivers for the label
printers are in the user profile and this class module functions fine on
other systems. The form USYS_PRINTDLG is required to be contained in the
database.

We use a specific printer in this reports page setup because the layout for
the labels is so different than for any other reports in the application.
I've stepped through the code and somewhere the UseDefaultPrinter variable
is getting set to true.

Any suggestions will be appreciated.
 
K

Ken Sheridan

If you are using Access 2002 or later, have you considered setting the
Printer property of the Application object? As an example the following is
the class module of a form which allows a printer to be selected and then
opens another form in dialogue mode from which the report is selected:

Option Compare Database
Option Explicit

Dim strDefaultPrinter As String


Private Sub Form_Load()

Dim prt As Printer
Dim strPrinterList As String

' get device name of default printer
Set Application.Printer = Nothing
strDefaultPrinter = Application.Printer.DeviceName

' build value list of installed printers
For Each prt In Application.Printers
strPrinterList = strPrinterList & ";" & prt.DeviceName
If prt.DeviceName = strDefaultPrinter Then
strPrinterList = strPrinterList & _
" <Windows default printer>"
End If
Next prt

' remove leading semi colon and assign value
' list to list box's RowSource property
strPrinterList = Mid(strPrinterList, 2)
Me.lstPrinters.RowSource = strPrinterList
' select default printer in list box
Me.lstPrinters = strDefaultPrinter & _
" <Windows default printer>"

End Sub


Private Sub lstPrinters_AfterUpdate()

' set application printer
If InStr(Me.lstPrinters, "<Windows default printer>") > 0 Then
Set Application.Printer = Nothing
Else
Set Application.Printer =
Application.Printers.Item(Me!lstPrinters.Value)
End If

End Sub


Private Sub cmdPrintReport_Click()

On Error GoTo Err_Handler

Dim strReport As String

' hide this form and open dialogue form to select report
Me.Visible = False
DoCmd.OpenForm "frmSelectReport", WindowMode:=acDialog
Me.Visible = True

' selected report name is passed back from
' dialogue form to hidden control in this form
strReport = Me!txtReportName

' print report
DoCmd.SelectObject acReport, strReport, True
DoCmd.PrintOut acPrintAll
DoCmd.SelectObject acForm, Me.Name

Exit_Here:
Exit Sub

Err_Handler:
MsgBox Err.Description
Resume Exit_Here

End Sub


Private Sub cmdRestoreDefault_Click()

' restore windows default printer
' and select in list box
Set Application.Printer = Nothing
Me.lstPrinters = strDefaultPrinter & _
" <Windows default printer>"

End Sub


Private Sub Form_Close()

' call Click event procedure of button
' to restore default printer
Call cmdRestoreDefault_Click

End Sub

While the above defaults to the Windows default printer you could of course
select any installed printer in the form's Load event procedure.


Ken Sheridan
Stafford, England
 
T

tjacobi

Thanks for the reply. The PrintersClass we have does something along these
lines, which I think is why they require the form USYS_PRINTDLG to be
included in the forms list. The class uses several API calls so I will look
into some of these but I'm beginning to suspect there is an issue with
recognizing the installed printers in the users profile. The PrintersClass
calls up a dialog box which shows all the installed printers, I select a
label printer, it returns with True (that a selection was made), but down
the line the path variable converts to the default printer and the
UseDefault variable changes from False to True. If I can't get this
corrected I can use your information but to temporarily set the default
printer to a label printer from the list. I know that part works of what you
sent me works as I've already added it onto a test form.

I've contacted ATTAC but no reply. They listed this newsgroup as a place to
go for information which I've gotten. Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top