Link to home
Start Free TrialLog in
Avatar of MoonDoggie
MoonDoggie

asked on

Using Winspool.drv to print an access report

I would like to click a button on an Access form (Access 2003) and open the print dialog, set properties (in this case 2-sided printing) and print a report that I've passed in.  I have code that uses the winspool.drv API to open the print dialog but it doesn't print anything, just sets properties but then they don't stick if I then open the report.  Can someone tell me which winspool function I use to send the report to the printer?
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MoonDoggie
MoonDoggie

ASKER

Thanks for the response, Jeff.  The reason I'm not using the standard dialog box is that this application is very locked down.  The way it was built is that when a report is opened, it is pop-up and modal.  Then a little form is opened pop-up on top of that.  The form has a print button and a close button on it.  If I place a button on the form to open the dialog, it will want to print the pop-up form, not the report.  I toyed with hiding the form first etc.,  but then if the user cancels out of the dialog, I don't see a way to trigger the form to unhide.  After trying different methods I decided the best way would be to use the API to open the dialog but I havent figured out how to pass it a report name to print.
MoonDoggie,

<this application is very locked down.>
You did not mention this in your original post.

<but then if the user cancels out of the dialog, I don't see a way to trigger the form to unhide. >

In my sample, the Report Prints, not the Form.
Are you saying that this was not the case when you tried it?

<After trying different methods I decided the best way would be to use the API to open the dialog >
There is a way around that without using API's, but if you have already decided on this, then there is no need to discuss it.

JeffCoachman
My apologies.  Your sample works.  I already have the report open when the user clicks the button for print properties, therefore when I adapted your code I didn't try to open it again, but that is the very line that makes it work.  It takes the focus off the pop-up form for the dialog box.

I was also surprised to see that with echo off the dialog appears.  I would have thought that it would not.  

Thanks for your help, Jeff.

Mike
<I was also surprised to see that with echo off the dialog appears.  I would have thought that it would not>
Me too, but I have used this technique many times and I am just greatfull that the dialog box does appear!
;-)


Jeff