Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Run command to close report after printing

Posted on 2014-02-07
2
Medium Priority
?
1,119 Views
Last Modified: 2014-02-08
I have a report that a user presses a button to open and preview.. I would like to close the report if the user prints the report... after it has printed.

Is this possible?
0
Comment
Question by:thandel
2 Comments
 
LVL 85
ID: 39843865
As far as I know, there is no event that occurs only when printing to a printer. There is a "Print" event in the report's model, but that occurs when the report is opened and shown on screen.

You could remove the built-in Access print methods and create your own custom toolbar that includes a Print comment, and you could then close the report after that. Be a pain, and honestly most users don't expect a document to disappear simply because it's printed.
0
 
LVL 16

Accepted Solution

by:
Sheils earned 2000 total points
ID: 39844590
As a work around you may insert a message box to ask the user if they want to print the document. This will allow you to close the report programatically if they select yes. Use the following code in the reports on Open event

Private Sub Report_Open()

Dim i as Integer

i= msgbox("Do you want to print this report",vbYesNo)

if i=vbYes then

DoCmd.RunCommand acCmdPrint
docmd.Close

End If
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

810 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