Link to home
Start Free TrialLog in
Avatar of shambalad
shambaladFlag for United States of America

asked on

No print option in report preview window

I must be stuck on stupid today...
I'm at a client site, working on an Access 2007 application I wrote many years ago.
A report is opened from a form. The report opens OK, it displays on the screen in its own window. But there's no option to print the report(?) The only thing it appears I can do is close the window. I thought there used to be a command button to print the report. What am I missing?
This is the command I am using to open it (The report name is loaded to variable strRpt):

DoCmd.OpenReport strRpt, acViewPreview, , , acDialog
Avatar of Trent Smith
Trent Smith
Flag of United States of America image

Private Sub ButtonName_Click()
DoCmd.OpenReport "ReportName", acViewNormal, "", "", acNormal
End Sub
Of course you can add to the code, in fact some report codes will filter the report, change formating if certain things are true or not, print a copy then send another copy to an e mail address, print a number of copies with different headers or footers, etc. etc. the list is almost endless.  

Private Sub ButtonName_Click()
'do something here before the report is printed
DoCmd.OpenReport "ReportName", acViewNormal, "", "", acNormal
'do something here after the report is printed
End Sub
for example (I know it's a silly example :-)

Private Sub ButtonName_Click()
If MsgBox("Are you sure you want to print the report?", _
vbQuestion + vbYesNo) = vbYes Then
DoCmd.OpenReport "ReportName", acViewNormal, "", "", acNormal
End If

By the way I love the opening comment.
Avatar of Jeffrey Coachman
With the new "Ribbon", (Access 2007 and newer) the Print icon will appear on the ribbon when the report is opened
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 shambalad

ASKER

Thank you for the responses. I had a feeling I was missing some obvious points. I will be back there at the site tomorrow morning. I'll close out the question then.
Todd
As you point out, Jeff, the reason I am seeing the report in a window with no options is because the report has been opened using the acdialog option. Unfortunately, this is 'by design'.
This application was originally written back in 2002 using Access 2000. It's actually pretty complex, and large. It has many forms, reports, queries, etc.
As I recall, one of the design issues was maintaining the 'precedence' of the forms. That is to say; some of the operations may go 4 or 5 forms deep. If the user was on the 5th opened form, we had to ensure they didn't click back to the 3rd opened form without closing the 5th, then the 4th forms first. As a result, each of the forms is opened in dialog (and, I'm thinking maybe modal) mode. Yes, it's kind of klugey, but the whole package actually 'works' pretty well, and has so for many years now.
Anyway, because of this, the only way to get the report to open in a window in front of the form where the command to run the report has been clicked is to open it using the 'acdialog' option.
If I remove the 'acdialog' option, the report can be viewed, but the user has to close a couple of forms to actually get to that window (whereupon they have the ribbon options to print).
That may be the way I have to go here.
However...
When I wrote this app, I put a wrapper/function on the OpenForm so that I could dynamically change the parameter defaults from a single data point. I'm going to play with this a little and see if I can't find another way through this.
I am actively working on this problem, and will close this quesion sometime today.
Thanks,
Todd

A developer's lament/digression:
This app has become something of a maintenance nightmare for me. It needs to be re-written.
At one point, I started doing a re-app for 64-bit, and in no time found myself butt deep in alligators, so to speak. Really don't want to re-visit that swamp.
The app has extensive links to Excel, which wasn't an issue until they started to upgrade MS Office in piecemeal fashion. This is app is being run on PCs, any of which may have installed Office 2007, 2010 or 2013. Even changing all the references to late-binding won't be trivial.
I'm removing the acdialog option from OpenReport.
Thank you for your assistance.
Todd
A quick workaround might be to add a button directly on the report to Print it out.
Then open the Report in "Report View".
 
You must set the: "Display When" property of the button to: "Screen Only" so that the button appears on the report (so you can click it), ...but it will not appear on the actual Printout (hard-copy)

Sample attached
Database891.mdb
That's a really good idea. Thank you. I'm going to give that a try when I'm back in the office Monday morning.
Thanks again.
Todd