Solved

How do I immediately call up the printer dialog window when I open an Access report?

Posted on 2008-10-23
13
284 Views
Last Modified: 2013-12-05
I am developing an Access (adp) project as a front end to a SQL Server database.
I have created an Access Report to print a customer order, and I can open this report from the underlying Form containing the customer order.
I have the Report displayed in "Print Preview" mode where the user can then select the printer icon to launch the printer dialog window. I would like to edit the Report's "On Current" procedure so that the printer dialog window is automatically opened when the Report is displayed.
This would make life easier for the operator and hopefully also solve another slight problem. I try to keep the underlying Order Form "modal" so that users don't wander off-track. Unfortunately this prohibits the user from interacting with the Report when it is opened. If I open the Report in "popup" and "modal" modes I can work with the report but lose the printer icon.
How do I call the print dialog window?

Many thanks. Colin.
0
Comment
Question by:colinasad
  • 5
  • 4
  • 4
13 Comments
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 22788346
Here's the code that will work:

  DoCmd.RunCommand acCmdPrin

You'll have to give a thought to what report's or report section event to put it into, and how to run it only once. Note that reports don't have OnCurrent event.
0
 
LVL 40

Assisted Solution

by:Vadim Rapp
Vadim Rapp earned 100 total points
ID: 22788353
i.e.

DoCmd.RunCommand acCmdPrint
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22794478
vadimrapp1,

In Access 2007, the Report object now has a "Current" event.
;-)

Jeff
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 400 total points
ID: 22794552
colinasad,

Are you sharing the same account as this user?:
http://www.experts-exchange.com/M_3466002.html

Because you have asked the identical question, ...so see this link to the question and solution:
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Access_Reports/Q_23719795.html

JeffCoachman
0
 

Author Comment

by:colinasad
ID: 22794701
Hi Folks,
I just came on to see if there was any responses, thanks for your time and suggestions.
Jeff, I have no connections with the other user you mentioned, but it looks like he is trying to achieve exactly the same effect as me. That is ...
Click on a "Print" button on a host Form, open and display a Report (based on the underlying Form) in a pop-up, modal "preview" window and immediately (and automatically) superimpose the standard "print dialog" window so that the user can select the required printer and print the report.

I have tried using the "DoCmd.RunCommand (acCmdPrint)" in various of my Report's events but with no success. It just doesn't appear on the screen in most events (including "On Current" ) and in others where it does get displayed (eg "On Load") it is too "early" and the report hasn't properly been formatted. I even tried the "On Timer" event in the hope that I could have the "Print Preview" displayed on the screen for a second or so before bringing up the "print dialog" box, but it just didn't appear.
I will have a go at the suggestions you gave to the other user and get back to you.

Regards. Colin.
0
 

Author Comment

by:colinasad
ID: 22795113
Hi Jeff,
The piece of code you suggested for the other user worked OK for me.
I guess I was taking the wrong approach in trying to control things from within the "Report" itself rather than within the "Print_Click" procedure of the host "Form". Many thanks.

2 little queries just before I close the question :
1. What role does the "DoEvents" call do in this? Its not something I have come across before and without it, the preview report window was empty. With it, I could see my expected report. I have done a quick search for "Help" on "DoEvents" but am none the wiser. I'm told it "relinquishes control to the Operating System", but can you tell me in layman's terms why it is needed in this instance?

2. My expected report does appear in a window with the "print dialog" box on top of it - perfect. But when I move the "print dialog" box around in order to see the print preview, the underlying print preview is not refreshed and the area(s) previously covered by the "print dialog" is completely blank. As the "print dialog" box is moved around more, the print preview is eventually completely wiped clean.
Not a major problem, but since I am offering the operator a chance to look at the preview before it is printed, it is a slight annoyance.
Many thanks for your help. Colin.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 22795171
Colin, are you sure you tried DoCmd.RunCommand in the events of the report? All the events you mentioned, OnTimer, OnCurrent, OnLoad - they exist for the forms, but not for the reports. You need to put this code in the report, not in the form that calls the report.
0
 

Author Comment

by:colinasad
ID: 22795220
Hi vadimrapp1,
I was indeed using the Events in the Report rather than the underlying host Form. I had opened the Report in Design View and was selecting the Events from the Properties pane.
I did not have much success with that strategy, but when I used the piece of code Jeff provided (placed in my "Print" command in my host Form) I achieved the effect I was after (apart from the minor glich mentioned as point 2 in my previous post).
Regards. Colin.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22798221
vadimrapp1,

  "All the events you mentioned, OnTimer, OnCurrent, OnLoad - they exist for the forms, but not for the reports."
Again, These properties DO exist for Reports in Access 2007, which is what colinasad is using.
;-)

Jeff
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 22798270
Thanks Jeff, I see.

Curious, how can OnTimer event work in a report.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22798302
colinasad,

On Point 1:
"DoEvents" will make the code wait until the previous operating has finished before continuing.
If I left it out, the Dialog box pops up on top of the Report, but the report is Blank.

On Point 2:
Yeah, it is funny, I got it to.
The only explanation is that this might be happening because the dialog box is modal.

JeffCoachman
0
 

Author Closing Comment

by:colinasad
ID: 31509220
Thank you both for your help.
Apart from the minor "Point 2" its working well.
I've tried to share the points fairly.
Thanks & regards.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22799394
vadimrapp1.

"Curious, how can OnTimer event work in a report."
Flashing controls immediately comes to mind.

As you probably know, the functionality of Forms and Reports is converging.

Whether this is good or bad, I think, remains to be seen.

I personally think that the functionality should remain somewhat separated.
If not, then why bother having two separate objects?

We have seen lots of questions here from new users wanting to make a report act like a Form and vice versa.
This always causes some confusion.

I think the reason this was done was that a lot of people wanted the Reports to be more "Interactive".
(Click a button on the report to change the Sort, have Clickable Hyperlinks, ...ect)

In Access 2002, I wondered why Reports were given Modal and Hidden properties, now I often use these properties/Events.
;-)

Jeff
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now