By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,910 Members | 1,085 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,910 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Feb 24 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
i8*******@yahoo.com wrote:
< SNIP >
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?

< SNIP >

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Access 2003 is easier than Access 95 (which is the example you gave).
To set the Default printer do this:

strPrinter = Application.Printer.DeviceName

strPrinter will hold the name of the default printer.

To set a printer you have to know the index number in the Printers
collection.

' Find the index number of the default printer
i = 0
Do While Application.Printers(i).DeviceName <> strPrinter
i = i + 1
Loop
' i now equals the index of the default printer

To change the Applications default printer:

Set Application.Printer = Application.Printers(i)

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ/9fRYechKqOuFEgEQI6dgCghIYppGooQAvV17NGADti8IMXLgQA oM+Y
j/YbyXw5+qaLQctcgYhSkINR
=uRu7
-----END PGP SIGNATURE-----
Feb 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.