PC Review


Reply
Thread Tools Rate Thread

Control de Print Dialog Control

 
 
Edgar
Guest
Posts: n/a
 
      27th Mar 2010
Hi,
I've been searching on the web for a tip to help me control the event when
OK Button is pressed for the Print dialog box. I need to get the number of
copies selected, and the printer, as well.
Any help would be greatly appreciated.
--
Edgar Rey
 
Reply With Quote
 
 
 
 
Jack Leach
Guest
Posts: n/a
 
      27th Mar 2010
Check out the DoCmd.PrintOut method in the VBA help file... this should give
you the options you are looking for. The PrintOut method prints the active
database object, so, if printing a report, you need to make sure the report
is open an selected before invoking the method. The code behind your OK
button's click event will look something like this (add arguments as
required)...


Private Sub btnOK_Click()
DoCmd.OpenReport "reportname", acPreview 'open the report
DoCmd.SelectObject .... 'make sure the report is selected
DoCmd.PrintOut... 'print the report with the desired parameters
DoCmd.Close acReport, "reportname" 'close the report
End Sub


The downside to this is that, because the report needs to be selected, you
can't do this in 'hidden' mode - you can't hide the report opening from the
user. For some people this is an issue, others not.

As an alternative, versions 2002+ have a Printer object. The default
printer object is Application.Printer, and each report also has a specific
Printer object where details for that particular report can be set (page
setup, margins, color, etc etc). While utilizing the Printer object, you can
get the 'hidden' report printing to work, though the process is a bit more
involved.

For versions earlier than 2002, to accomplish the above in place of the
Printer object, you need to use the PrtDevMode stuff - I'm not familiar with
this myself, but some examples can be found at the www.mvps.org/access site.
I'm pretty sure the learning curve behind this method is much greater than
using the Printer object, so hopefully you don't have to go there.

Probably DoCmd.PrintOut is your best bet.

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"Edgar" wrote:

> Hi,
> I've been searching on the web for a tip to help me control the event when
> OK Button is pressed for the Print dialog box. I need to get the number of
> copies selected, and the printer, as well.
> Any help would be greatly appreciated.
> --
> Edgar Rey

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing using the print dialog control in vb.net 2005 Brad Pears Microsoft VB .NET 2 13th Mar 2007 11:02 AM
adding a custom control to print preview dialog =?Utf-8?B?bWFyaw==?= Microsoft VB .NET 5 26th Jan 2005 12:11 AM
Print preview dialog control Jabax Microsoft VB .NET 0 27th Mar 2004 05:09 PM
Print preview dialog control problems Omavlana Omav Microsoft Dot NET Compact Framework 1 13th Oct 2003 03:40 PM
Print preview dialog control .. problem Omavlana Omav Microsoft Dot NET Framework Forms 2 13th Oct 2003 11:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:31 AM.