![]() |
![]() |
All Products | Support | Search | microsoft.com Guide | |||||||||||||||
![]() | |||||||||||||||||
| |||||||||||||||||
| October 6, 1997 | Back to Microsoft Access Articles and Sample Apps | |
|
Using Microsoft Access 97 or Access 2000 Report Snapshots and the Snapshot Viewer Save trees while you electronically distribute your Microsoft Access reports
Mark Gillis and David Shank, Microsoft Corporation Contents |
|
Distribute your Microsoft Access reports the modern way |
|
You regularly print and distribute Microsoft® Access reports to users inside and even outside your organization. But you want an alternative to printing, photocopying, and mailing these reports, because you're spending way too much money. Besides, you'd much rather send them in e-mail or post them to a Web site for quick and easy access. Now that you think of it, you want your users to view these reports in full fidelity, including color, fonts, charts, and other embedded objects. While you're at it, throw in a user-friendly interface, and an exposed object model so you can program it just the way you want to. To top it off, you want all this without your users' needing a full or run-time Microsoft Access license to view and print Microsoft Access reports. Well, that sounds like a tall order, but . . . no problem! The combination of report snapshots and Snapshot Viewer will fill the bill quite nicely. What is a report snapshot and what is Snapshot Viewer?Think of a report snapshot as a portable Microsoft Access report. A report snapshot file, with an .snp extension, contains a full-fidelity copy of each page of a report and preserves the report's two-dimensional layout, graphics, and other embedded objects. Think of Snapshot Viewer as a portable Print Preview. It's a program you use to view, print, and electronically mail a report snapshot. Snapshot Viewer consists of a stand-alone executable program, a Snapshot Viewer control (Snapview.ocx), a Help file, and other related files. You can use the Snapshot Viewer control to view a report snapshot from Microsoft Internet Explorer version 3.0 or later, or any application that supports embedded objects, such as Microsoft Word, or ActiveX® controls, such as Microsoft Visual Basic® for Applications (VBA). |
|
Comparing information in two related reports |
What you needMicrosoft Access 97 Service Release 1 or later, or Microsoft Access 2000 The ability to create a snapshot report was first delivered in Service Release 1 (SR-1) of Microsoft Access 97 and is also available in Microsoft Access 2000. To create a snapshot report, you need one of the following versions of Access or Office:
If you are using Microsoft Access 97 and are not sure that you have SR-1 or later, click About Microsoft Access on the Help menu. If SR-1 or later is at the top of the About Microsoft Access dialog box, you're all set -- you can create report snapshots. If not, see information about downloading the current service release of Office 97 from the Office Update Web site. Snapshot Viewer Although you must have Microsoft Access 97 SR-1 or later to create report snapshots, you don't need a Microsoft Access license to view or print them, send them via e-mail, or publish them on the Web. All you need is Snapshot Viewer, which you can install from these sources:
Snapshot Viewer works with Microsoft Windows® 95 or later and Microsoft Windows NT® 3.51 or later. If you are using Microsoft Windows NT version 3.51, the Snapshot Viewer control (Snapview.ocx) requires Service Pack 5 or later. Microsoft Outlook and Microsoft Internet Explorer 3.0 To send a report snapshot via e-mail, you'll also need an electronic mail client program that supports Messaging Application Programming Interface (MAPI), such as Microsoft Outlook. To display a report snapshot on the World Wide Web, you'll also need a Web browser that supports ActiveX controls, such as Microsoft Internet Explorer 3.0 or later. Optional: Snapshot Viewer on your intranet When you send a report snapshot via e-mail or distribute one on the Web, it's a good idea to always include a link to the software download page for Snapshot Viewer, in case your users don't have Snapshot Viewer installed. For better performance and user convenience, you may want to set up a local site on your corporate intranet for downloading the Snapshot Viewer. Here are the general steps:
Note These steps aren’t necessary for users of Access 2000 or Office 2000 viewing a snapshot report in e-mail, because the setup program in these versions automatically installs Snapshot Viewer the first time a user opens a snapshot report from e-mail or the file system. Create a report snapshotTo create a report snapshot in Microsoft Access 97:
To create a report snapshot in Microsoft Access 2000:
A report snapshot is based on the table or query behind the report, including any sorting or filtering defined by the current OrderBy or Filter property settings. If the report is based on a parameter query, Microsoft Access first prompts you for the parameter values, and then outputs the results. Open and view a report snapshot in Snapshot ViewerTo open a report snapshot, just double-click the report snapshot in Windows Explorer.
Once your report snapshot is open, you can: |
|
|
To view the report at different magnifications, right-click the report snapshot, point to Zoom, and then click Fit, Fill, or a magnification percentage. When you choose Fill, Snapshot Viewer adjusts the magnification of the page to fill the window. If the report is in portrait orientation, the report width or short side of the page fits the window; if the report is in landscape orientation, the height or short side of the page fits the window. Now your users can easily and quickly view Microsoft Access reports online. And they can print only the report pages they need. The page numbers are in the box at the bottom of the Report Snapshot window. Selective printing is especially useful when your reports contain color and images, such as charts and pictures, which can take a long time to print. Troubleshoot opening a report snapshot
Send a report snapshot in electronic mailSend a report snapshot as an embedded icon You can send a report snapshot as an icon in e-mail by clicking Send on the File menu in Snapshot Viewer.
You can also send a report snapshot via e-mail as an icon by selecting a report in the database window, and then clicking Send on the File menu in Microsoft Access 97, or by clicking Send To on the File menu in Microsoft Access 2000. Even better, create a macro that uses the SendObject action to automate the process. For example: Send Snapshot macro
Note The previous example uses the Northwind Traders sample database of Microsoft Access. If this database is not installed on your computer, search Microsoft Access Help for "Northwind database." Send a report snapshot as an embedded object You can embed a report snapshot as an object in an e-mail message by using an electronic mail program that supports embedding objects. For example, in Microsoft Outlook click Object on the Insert menu; click Create from File, and then type the report snapshot file name in the File box, or click Browse to search for the file. Your message must be composed using the Microsoft Outlook Rich Text format to support embedded objects. When your e-mail recipients read the e-mail message, they can double-click the embedded snapshot report to activate Snapshot Viewer in place and read the report. |
|
|
|
Notes
Distribute report snapshots regularly on the World Wide WebIf you regularly distribute lots of reports, such as weekly stock-level reminders, monthly sales reports, or quarterly financial statements, you may want to use the World Wide Web as a sort of "report clearinghouse." Create report snapshots automatically To automate the creation of your reports, create a macro in Microsoft Access 97 or 2000 that uses the OutputTo action (one for each report you want to output) to export each report as a report snapshot to the Web server where you publish your reports. For example: Create Snapshot macro
Publish your report snapshots Once you have created your report snapshots, there are two ways you can publish them on the World Wide Web: 1. Create a link to each report snapshot. Use a HyperText Markup Language (HTML) Anchor tag on a Web page. For example: |
|
|
When your users click the link, Microsoft Internet Explorer activates the report snapshot and Snapshot Viewer in place in the Microsoft Internet Explorer window. Other browsers open the report snapshot in a separate Snapshot Viewer window. In either case, Snapshot Viewer must be installed on the same machine as the browser. Therefore, it's a good idea to provide an additional link on the Web page to a software download page for Snapshot Viewer, in case your users don't have Snapshot Viewer installed. |
|
|
2. Embed the Snapshot Viewer control on the Web page. Use the HTML Object tag. For example: |
|
|
You can embed the Snapshot Viewer control by using a Web page editor such as Microsoft FrontPage®. However, you can only use this method if you and your users are running a browser that supports ActiveX controls, such as Microsoft Internet Explorer version 3.0 or later. To automatically download and install the Snapshot Viewer control for users who don’t have Snapshot Viewer, you can copy the Snapview.ocx file to a Web server on your corporate intranet and use the Codebase attribute of the HTML Object tag. For example: |
|
|
Schedule the creation and publication of your report snapshots To regularly schedule the whole process, you can use a scheduling program, such as Windows NT AT, Microsoft Plus! System Agent, or Windows 98 Task Scheduler. For example, create the following batch file to run your Create Snapshot macro: Batch file: Webpost.bat |
|
|
And then use System Agent (SysAgent.exe) to run the batch file for you on a regular schedule.
Troubleshoot opening report snapshots from a Web page If you are attempting to open the report snapshot from a Web page, you may experience a connection or time-out problem while the report snapshot is being downloaded. Redisplay the Web page, or restart your Web browser to see if that fixes the problem. Do it your way: two sample applicationsLet's say your company keeps customer and sales data in a Microsoft Access database at company headquarters. In the past, when an employee in the home office needed to see a report, you had to print the reports and send them through inter-office mail. Or when one of your traveling salespeople needed a report, they telephoned or sent an e-mail request and you faxed back the report. But now you want to take full advantage of report snapshots and the Snapshot Viewer. The following sample applications show how you can customize the viewing and distribution of report snapshots to fit the unique needs of your company. The SnapshotBrowser sample application: viewing and printing reports on a network server (To view the complete source code for this application, click here.) You now want to make all reports available online to employees in the home office. Although no employee has direct access to the company's Microsoft Access database, there is a shared network server available that employees can use to store and exchange files. So, you create a folder named Reports on that network server and a subfolder for each month of the year. Then for every report that is created during the month, you save it to the corresponding subfolder as a report snapshot. Finally, you instruct your users to run the SnapshotBrowser application to view and print any report snapshot for any month of the year in the Reports folder. The SnapshotBrowser sample application
SnapshotBrowser, a Microsoft Visual Basic 5.0 application, uses a single form that contains a Snapshot Viewer ActiveX control (Snapview.ocx) and a TreeView control. The TreeView control is used to browse the snapshot files stored in the Reports folder on your network server. When the application starts, it loads the TreeView control with the names of the months representing the subfolders that contain the snapshot reports. The application uses class modules to represent the month subfolders and each report contained in a month subfolder. A custom function fills a Months collection object with a Month object for each month subfolder. The procedure then fills a Reports collection with a Report object for each snapshot file found in a month subfolder. (These are custom objects and collections and have no relation to Microsoft Access built-in objects and collections.) Following is the code used to fill the Months collection with Month objects: |
|
|
Once the Months collection is filled with Month objects, the FillReports function is called to fill the Reports collection for each Month object with Report objects for each report found. |
|
Note In the preceding code samples, the variables colMonths and colReports are Public variables declared in a standard module. When a user selects a month from the TreeView control, all the report snapshot files contained in that subfolder are displayed in the left pane of the application's main form. When a user selects a report snapshot from the TreeView control, the report is displayed using the Snapshot Viewer control. You use the SnapshotPath property to specify which snapshot file to display in the Snapshot Viewer ActiveX control. The SnapshotBrowser sample application sets this property using the following code: |
|
|
The variable gstrFolderPath contains the UNC path to the main Reports folder. Node.Parent.Text contains the name of the month subfolder and contains Node.Text, the report snapshot file name. Note If you want to use this sample application, you must make sure you set up the Reports and Months folders exactly as they are set up in this example. In addition, you must change the variable gstrFolderPath (found in the Declarations section of Module1) to the UNC path to the Reports folder on your network server. The Snapshot Viewer control exposes a SnapshotViewer object that contains properties, methods, and events you can use to programmatically manipulate all aspects of the control. For example, the following subroutine shows how the Print Report button calls the Snapshot Viewer control's PrintSnapshot method to print the report currently displayed in the control. |
|
|
For more information on programming the Snapshot Viewer control, view the Help file that comes with the Snapshot Viewer. The Help file provides language reference topics for all of the Snapshot Viewer control's properties, methods, and events. The AutomatedMailer sample application: round the clock remote access to multiple report snapshots via e-mail (To see the full source code for this application, click here.) Next, you decide to create an automated report snapshot mailer application. Your remote salespeople can now request reports by sending you e-mail and automatically receive the requested report snapshots embedded in the e-mail reply message. The AutomatedMailer sample application automates these e-mail reply messages, providing the requested snapshot files automatically. To get an automated e-mail reply containing snapshot files, the user creates an e-mail message addressed to you with the word "MailReport" anywhere in the message subject line. In addition, in the body of the message the user specifies the names of the reports requested as a comma-delimited list: "Reports: reportname1, reportname2, reportnameN" (for example, "Reports: Stock-level, Quarterly Statement, Top Customers"), and the name of the month subfolder where they're stored: "Month: monthname" (for example, "Month: September").
Note The code the parses the body of the e-mail message to determine the names of the requested month and reports will ignore any other text in the message. You must complete the following five steps for this sample application to work correctly on your machine:
The sample application, a Visual Basic 5.0 program, will automatically reply to any e-mail message asking for reports (when submitted in the proper format). The sample works by calling code at regular intervals to check for new e-mail in the MailReport folder. If the application finds an unread message in the MailReport folder, it parses the text in the body of the message to determine the specified month and reports requested. The code then creates a reply message, lists the reports requested, indicates whether each file was found in the specified month subfolder, attaches the requested report files to the e-mail message, and sends the reply e-mail back to the person requesting the reports. The AutomatedMailer application has one form that contains a Timer control. You use the Timer control's Interval property to specify (in milliseconds) how often to check for new e-mail in the MailReport folder. The sample also shows how you can change this Interval property while the application is running. The application uses the following custom function to check for new e-mail: |
|
|
If there is an unread e-mail message in the MailReport folder, then the ReplyToMail custom function is used to create and send the reply message. The ReplyToMail function uses the MailItem object's Reply method to create the reply. It then parses the body of the original e-mail message to determine the month and reports names specified. This information is used to attach the snapshot reports to the message reply. To determine the report names requested, the code parses the original message body, extracts each report name, and places the names in an array using the code: |
|
|
The ParseMail function uses the following code to enter each report name into an array and then return that array to the variable arrRequestedRpts in the ReplyToMail procedure: |
|
|
Once the array of report names is filled, the following code attaches each report to the e-mail message reply. Note how it modifies the e-mail message if an error occurs trying to locate the snapshot file in the specified file folder. |
|
|
After the reply has been created, it is sent using the MailItem's Send method and then the original e-mail message is deleted from the MailReport folder using the MailItem's Delete method. Summary The AutomatedMailer sample application illustrates how to automate e-mail replies to requests for report snapshots by following these steps:
|
|
|
|
|
||
|
Comments? Suggestions? Write us at MSDN@microsoft.com. |
||
| ©
2000 Microsoft Corporation. All rights reserved. Terms of Use. Last Updated: August 24, 2000 |
||
| Best experienced with Click here to start. |
||