Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 9th, 2007, 02:32 PM
Registered User
 
Join Date: Aug 2006
Location: , , .
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



Reply With Quote
  #2 (permalink)  
Old August 10th, 2007, 06:38 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old August 10th, 2007, 12:19 PM
Registered User
 
Join Date: Aug 2006
Location: , , .
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.

Reply With Quote
  #4 (permalink)  
Old August 10th, 2007, 12:31 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:47 PM.


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