Wrox Programmer Forums
|
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 August 9th, 2007, 02:32 PM
Registered User
 
Join Date: Aug 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening Reports

I have a form to allow users to view or print a report. To view the report, I have the following code that runs on a button click event:

Code:
DoCmd.OpenReport "rptTrans", acViewPreview
The PC that runs the report is connected to a label printer. If the default printer is set to the label printer the report is not viewable. I understand that the display is a preview of the printed report as it would look on a label.

Is there a command to view (not print) the report other than acViewPreview?

It's not that big of a deal. The user can always change the default. I would just like to know if there is another way.

Thanks



 
Old August 10th, 2007, 06:38 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hiya,

   I would do this:

On the button event that opens the report, add this code to change the default printer to a known good printer:

Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.SetDefaultPrinter("\\server\printer")

Then on the on close event of the report, put similar code to change back the label printer as the default.

Does that help?

I can also give you code to run this IF the default printer is currently the label printer, otherwise don't run. This will require a Public Boolean to store whether the printer was changed on open so that it may or may not be changed back on close.

Lemme know.


mmcdonal
 
Old August 10th, 2007, 12:19 PM
Registered User
 
Join Date: Aug 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mmcdonal,

Yes, that helps. What I'll do is have the code set the default printer on the open event. I'll have the user manually change the default back to the label printer as needed. The user will often be viewing more than one report at a time, so I don't want to automatically change to the label printer on the close event.

Thanks for your help.

 
Old August 10th, 2007, 12:31 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Actually, you can poll the printer objects to find the default printer, then only change it if it is the label printer. Then change it back automatically when the app closes.

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting filtered reports without opening dkirby123 BOOK: Access 2003 VBA Programmer's Reference 0 August 14th, 2007 06:21 PM
how to get reports in crystal reports using ASP3.0 candy133 Classic ASP Basics 2 January 26th, 2006 08:26 AM
comparision among crystal reports and Data reports avats Crystal Reports 0 April 13th, 2005 01:01 PM
How to create/design reports with crystal reports BassmaniaQ Crystal Reports 0 December 14th, 2004 04:58 AM
Reports Manager does not list reports hinesweb BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 July 25th, 2004 04:39 AM





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