Auto Report Print from Combo Command

L

Londa Sue

I created a combo box to allow for selection of an ID to drive the generation
of a report. The code is as follows:

Private Sub cmdOK_Click()

DoCmd.OpenQuery "qry_mainreport", acViewNormal, acEdit

DoCmd.OpenReport "41 Internal Project Audit Report", , , "IPAID= '" &
Me.cboIPAReport & "'"

DoCmd.Close acForm, "frm_SelectIPAID"

The issue I have with this is that the report automatically prints. After I
select an ID, the query runs, query table shows, and then the report prints.
What I would like it to do is have the report become viewable and then allow
the user to choose whether or not to print.

How should I adjust the code for this to happen?

Thanks as always,
 
A

Al Campagna

Londa Sue,
Try...
DoCmd.OpenReport "41 Internal Project Audit Report", acViewPreview , ,
"IPAID= '" & Me.cboIPAReport & "'"

acViewPreview let's you look at the report before printing/not printing.

By the by, not sure why you're calling "qry_mainreport?"
If that's the RecordSource for your report, there's no need to manually
call it... the report will do that.

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
L

Londa Sue

Wonderful!

Thank you.

Al Campagna said:
Londa Sue,
Try...
DoCmd.OpenReport "41 Internal Project Audit Report", acViewPreview , ,
"IPAID= '" & Me.cboIPAReport & "'"

acViewPreview let's you look at the report before printing/not printing.

By the by, not sure why you're calling "qry_mainreport?"
If that's the RecordSource for your report, there's no need to manually
call it... the report will do that.

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 

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