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)