Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 20th, 2004, 07:29 AM
Registered User
 
Join Date: Dec 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with printer switching

Hello, I've got the following problem.
I need to use two printers for different purposes. At first I used Set Application.Printer = Application.Printers(printername) to choose a printer and switch between a certain printer and the default printer. Everything worked fine but the problem was that this code could only be used with access 2002/3/xp and not with 2000. So I used the function

Public Sub SetDefaultPrinter(s As String)
'imposta la stampante passata come argomento a predefinita
On Error GoTo Esci
Dim WshNetwork As Object
If IsNull(s) Or s = "" Then Exit Sub
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.SetDefaultPrinter (s)
Set WshNetwork = Nothing
DoEvents
Esci:
End Sub

and it appears that this code works with access2000 but not access 2002. If I write

SetDefaultPrinter pdfPrinter
....
SetDefaultPrinter defaultPrinter

the second function call is executed but has no effect on the printers. I found out that the function works just the first time I run the routine.
I mean, if the printer is pdfPrinter, for example, and I delete the line SetDefaultPrinter pdfPrinter, there's no way to choose defaultPrinter. If I shut down access and then reload it, the call SetDefaultPrinter defaultPrinter works. (and vice versa)
I don't know how to solve the problem, it happens just with access2002 as far as I know.
Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Switching back to class instead of style nerssi Javascript 4 September 26th, 2008 03:12 AM
Switching TableAdapters striker9 ASP.NET 2.0 Basics 3 March 29th, 2006 11:11 AM
Printer.Printer Problem!! Pls Help Me Chamin Access VBA 0 December 10th, 2004 07:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.