PC Review


Reply
Thread Tools Rate Thread

After the default printer has been changed by code in Access 2003, the application still directs a report to the former default printer.

 
 
Peanuts
Guest
Posts: n/a
 
      24th Feb 2006
Could someone please help? I am using the 'defaultprt.zip' tool
provided by Ken Getz to change the default printer via VBA code (code
below). My problem is that once the default printer has been changed,
Access 2003 still directs the report to the former default printer.
Access 2003 picks up the new default printer setting only after I have
reopened the application. I have checked the default printer setting in

the OS control panel and the code works well. This problem also occurs
when an Access 2003 application is open and one changes the default
printer manually in the control panel (Windows 2000).

To me it seems that Access 2003 picks up the default printer setting
once at Application Start-up only. Is there a way that I can force
Access to "refresh" the default printer after I have changed it by
code without closing/reopening the application?


THANKS


Code to SET DEFAULT PRINTER by Ken Getz:
Option Compare Database 'Use database order for string comparisons
Option Explicit


' Code from:
' Microsoft Access 95 How-To
' (c) 1998 Ken Getz and Paul Litwin
' All rights reserved.


' You may only use this code as part of an application
' that requires its use. You must including this
' notice intact. You may not distribute the code
' as your own work, nor can you distribute the
' code on its own.


Private Function BuildName(dr As aht_tagDeviceRec) As Variant


' Build up the string in the format:
' HP LaserJet 4 on LPT1:
' for display in the combo box.


BuildName = dr.drDeviceName & " on " & dr.drPort


End Function


Private Sub Button0_Click()


DoCmd.Close


End Sub

 
Reply With Quote
 
 
 
 
Wayne Morgan
Guest
Posts: n/a
 
      24th Feb 2006
I believe that the code you mention was for Access 97. While it will still
change the default printer in Access 2003, you may find it easier to just
specify the printer you want to use instead of changing the user's default
and having to change it back again.

The following example is from the Access 2003 help file:
-----------------------------------------------------
The following example makes the first printer in the Printers collection the
default printer for the system, and then reports its name, driver
information, and port information.

Dim prtDefault As Printer
Set Application.Printer = Application.Printers(0)
Set prtDefault = Application.Printer
With prtDefault
MsgBox "Device name: " & .DeviceName & vbCr _
& "Driver name: " & .DriverName & vbCr _
& "Port: " & .Port
End With
-----------------------------------------------------

Even though it says that it changes the system's default printer, I show the
printer actually changes just in Access. If I check my Printers folder, the
default printer doesn't change. Also, other applications are still printing
to my system's default printer, not the printer chosen in Access.

The printer can be referred to using the index number as above or by its
name.

Example:
Set Application.Printer = Application.Printers("HP DeskJet 1220C Printer")

I tried changing my system's Default Printer in the printers folder and
Access stayed with the printer it saw as the default when it opened. I
suspect that this is also what is causing the problem with what you are
doing. Since Access now has the ability to set its own printer, it doesn't
requery the default printer. In fact, most applications that I use behave
this way. You either have to choose a printer within the application or open
the appliation again after changing the system's default printer.

--
Wayne Morgan
MS Access MVP


"Peanuts" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Could someone please help? I am using the 'defaultprt.zip' tool
> provided by Ken Getz to change the default printer via VBA code (code
> below). My problem is that once the default printer has been changed,
> Access 2003 still directs the report to the former default printer.
> Access 2003 picks up the new default printer setting only after I have
> reopened the application. I have checked the default printer setting in
>
> the OS control panel and the code works well. This problem also occurs
> when an Access 2003 application is open and one changes the default
> printer manually in the control panel (Windows 2000).
>
> To me it seems that Access 2003 picks up the default printer setting
> once at Application Start-up only. Is there a way that I can force
> Access to "refresh" the default printer after I have changed it by
> code without closing/reopening the application?
>
>
> THANKS
>
>
> Code to SET DEFAULT PRINTER by Ken Getz:
> Option Compare Database 'Use database order for string comparisons
> Option Explicit
>
>
> ' Code from:
> ' Microsoft Access 95 How-To
> ' (c) 1998 Ken Getz and Paul Litwin
> ' All rights reserved.
>
>
> ' You may only use this code as part of an application
> ' that requires its use. You must including this
> ' notice intact. You may not distribute the code
> ' as your own work, nor can you distribute the
> ' code on its own.
>
>
> Private Function BuildName(dr As aht_tagDeviceRec) As Variant
>
>
> ' Build up the string in the format:
> ' HP LaserJet 4 on LPT1:
> ' for display in the combo box.
>
>
> BuildName = dr.drDeviceName & " on " & dr.drPort
>
>
> End Function
>
>
> Private Sub Button0_Click()
>
>
> DoCmd.Close
>
>
> End Sub
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2003 report not using printer default settings anjee Microsoft Access Reports 2 8th Apr 2008 09:57 PM
store default printer, change printer and then restore default printer? Dennis Pedersen Microsoft Excel Programming 0 14th Nov 2007 09:18 PM
Access application not using default printer settings going though Citrix dons100 Microsoft Access Reports 2 2nd Aug 2006 04:23 PM
After the default printer has been changed by code in Access 2003, the application still directs a report to the former default printer. Peanuts Microsoft Access Forms 2 26th Feb 2006 06:32 AM
After the default printer has been changed by code in Access 2003, the application still directs a report to the former default printer. i8mypnuts@yahoo.com Microsoft Access Form Coding 1 24th Feb 2006 01:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:37 AM.