473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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

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
1 5419
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Wayne Aprato | last post by:
I have several Access 2003 mde databases. When I try to open them in Access 2002 I get the following error: "The Visual Basic for Applications project in the database is corrupt." ...
1
by: pw | last post by:
Hi, I can't find anything about a toolkit on Microsoft site or what is needed to distribute an Access 2003 application (like the SDK w/ Access 97). I assume this is still possible. What do I...
1
by: ellipsys | last post by:
- Open Access 2003 - Create new database (2000 or 2002/2003 format) - Create a report and insert a label in its Detail section - Save the report as Report1 - Copy Report1 as Report2 - Open...
1
by: musicloverlch | last post by:
OK, how do I get rid of the security warning whenever I open a database?? Thanks! Laura
9
by: Steven Munlo | last post by:
Hi, I have an Access 2003 application which I have to enhance. The former programmer isn't available any more. Does anybody know a good tool which documents Access 2003 applications? Steven
2
by: Midsomer | last post by:
Hi. I have an Access database with a form containing 4 datasheets and I allow the user to change column widths. On closing the form, a routine is fired that saves each column width to an INI file....
2
by: dick3425 | last post by:
I used register the crystl32.ocx then put the active X control (Crystal Report Control) on the form name it Report1 and write the following code assigned to a button: Private Sub cmdPrint_Click()...
2
by: chezhiananbu | last post by:
Friends, .I have Access 2003 installed and was working without any problem. But recently when I tried to open an Acces database application, I get an error message that states," A problem occured...
1
by: Joe Humburg | last post by:
Hi everyone, Looking for some help or ideas, on the folloiwng problem. Have an Access 2003 application that creates an Excel file containing data from an Access parameter query. This is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.