I would actually recommend that you use Stephens free solution to create a
PDF, and that way your software will function on machines that don't
necessarily have a version of Adobe installed. (that and more importantly
who will not have to actually changed printers to accomplish the goal of
sending the report to a pdf). (I should probably know that the solutions
100% free also).
For all of my report's in ms-access applications I always build *one* custom
menu bar called reports and use that for every single report that I make.
This custom menu bar will have an option to print to the default printer, an
option to print a specific printer, and e-mail option that will launch the
person's e-mail client with the current report we are viewing being
converted to pdf *and* attached to the email cleint we just launched. and
one could also add an save as PDF option to the menu bar.
The above stuff is quite difficult to do for using the Adobe printer driver
stuff, Stephens example code makes this rather easy to do (the email part
for example).
However for your current situation I guess the code programming logic behind
the but for the report to make a PF would be as follows:
1) save the users current default printer settings that they have
2) switched the printer to the PDF printer driver.
3) execute a print command will will send the reprot we are viewing to the
pdf write
(I assume that the PDF driver will prompt the user for location to save the
pdf file name at this point).
3) after the printing has occurred you reset (return) the default printer
back to whatever it was.
So when you create a custom menu bar, I would suggest that you have the
following code for the button on the menu bar run :
So, to save/switch, you can use:
dim strDefaultPrinter as string
' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName
' switch to printer of your choice:
Set Application.Printer = Application.Printers("Adobe printer name
whatever")
do whatever. (something like)
Dim strReportName as string
strREportName = Screen.ActiveReport.Name
DoCmd.SelectObject acReport, strReportName
DoCmd.PrintOut acPrintAll
Swtich back.
Set Application.Printer = Application.Printers(strDefaultPrinter)