Printing from msgbox vbOK button

J

Jessica

Greetings!

I have a button that creates a query based on user input
in order for them to export or print the query. I have a
msgbox that pops up when the user clicks to print the
query with a vbokcancel combination. How do I get the
query to print when the user clicks ok? I've tried a
variety of things but I can not get it to print or even
print preview.

Also is there a way to set up the page-set up for that
query that will remain constant? I need this query to
print in landscape view to contain all the fields.

Thanks!

Jessica
 
A

Andrew Smith

Don't print the query direct - make a report based on the query and print
that. You can save the print settings with the report.

You use DoCmd.OpenReport "NameOfReport" to print a report from code. There
is an optional argument to use for preview a report, but I can't remember
what it is and I'm too lazy to look it up!

For the message box, put:

If MsgBox("Do you want to print",vbOKCancel) = vbOK then
DoCmd.OpenReport ...
End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top