Thanks to Microsoft Access's easy-to-use report generator, it's easy to share data with just about anyone—anyone that has Access that is. Your users and clients can easily e-mail an Access report, as long as the recipient has Access. If that's not the case, your clients have a rather archaic alternative: They can print the report and then mail, fax, or carry the report. In today's automated world, the idea of hand carrying, faxing, or even mailing reports via the regular mail probably doesn't sit well with your clients. Nobody wants to wait for the information they need any longer than necessary, and why should they? Your clients and users want to send reports via e-mail or post them directly to a Web site for quick access, and they can—if you introduce them to the Snapshot Viewer utility.
About Snapshot Viewer
Snapshot Viewer (Snapshot) is a utility that creates a picture—a snapshot if you will—of an Access report. It's a lot like Access's Print Preview feature, but without Access. This utility creates a perfect copy of an Access report in a non-Access format (.snp). The report retains all of its formatting, graphics and embedded objects so the recipient sees exactly what you see. The only difference is that the recipient doesn't have to have Access to view the report. The one limitation is that the recipient can't alter the snapshot file; for most people, this won't be a problem.
Snapshot is a simple utility with only a few components: an executable program, a Snapshot Viewer control, and a Help file. It has only one purpose—to create and display pictures of an Access report. Using Snapshot, you can also print and electronically mail reports.
You can view, print, store, publish, and distribute a report snapshot without having a license for Access although the person creating the snapshot file must have a licensed version of Access. There are no license requirements for downloading, installing and using Snapshot to view snapshot files. The most important thing to get across to your clients is that the recipients must have a copy of Snapshot. It's free and easy-to-use so few will complain about this simple requirement. Your clients probably should include a link to Snapshot when they e-mail snapshot files (at least until they're sure the recipient has Snapshot).
Versions of Access before 97 do not support the Snapshot utility. In addition, Snapshot requires Access 97 (SR-1) or Office 97 Professional Edition (SR-1), or later. (We'll be working with Access XP and the latest version of Snapshot, Snapshot Viewer 9.0 in our examples.) Snapshot also requires Windows 95 or later, or Windows NT 3.51 (Service Pack 5) or later.
Those clients without Access, but in need of Snapshot can download Snapshot from the Microsoft Web site. Access 97 users (with SR-1 or SR-2) can find Snapshot on their Office 97 CD-ROM in the ValuPack folder (look for Snpvw80). Access 2000 and Access 2002 users will automatically install Snapshot (9.0) the first time they create or view a snapshot report.
Show clients how to do it
Regardless of which Access version you're using, creating a snapshot file is as easy as exporting a report. Therefore, depending on the relationship you have with your clients, a quick training session may be all that's needed. Use the following two examples to illustrate exporting snapshot files via the Access user interface. Specifically, you (or your client) will export the Catalogs report in Northwind (the sample database that comes with Access) as a snapshot file. To do so:
- After launching Northwind, select Reports in the Database window.
- Chose Export from the File menu, and then choose Snapshot Format (*.snp) from the Save As Type control in the Export Report dialog box. (Access 97 users should choose SaveAs/Export from the File menu, select To An External File Or Database in the Save As dialog box, and click OK.)
- Access will assume the name of the data source as the new snapshot file's name. You can change it if you like, but don't bother with that in this example. At this point, you can also determine where the file is stored by selecting a new folder in the Save In control.
- The AutoStart option is selected by default, as shown in Figure A. Left enabled, Access will open the new file in Snapshot for you to view. Uncheck this option if you want to create the file without viewing it.
- Click Export (with AutoStart checked) to create the new .snp file. The new file is shown in Snapshot, within the Access window, as shown in Figure B. Use the familiar Windows buttons in the title bar to maximize, restore, and close the Snapshot window. Use the navigation bar at the bottom of the window to browse through the pages—all the data is there in just the same format as if you were using Access Print Preview.
|When enabled, the AutoStart option will display the new snapshot file in Snapshot.|
|Snapshot displays the new snapshot file.|
E-mailing a Snapshot file
E-mailing the report is just as simple. Just remember, you're not saving the snapshot file locally as you do when you export the file. To e-mail a snapshot file:
- After launching Northwind, select Reports in the Database window.
- Choose Send To from the File menu, and then select the Snapshot Format option in the Send dialog box shown in Figure C, and then click OK.
- Doing so will open the default mail client assuming two default settings: your e-mail address in the From control and the Catalogs.snp file in the Attach control. At this point, supply the recipient's e-mail address in the To control, add Subject text and enter a message, as shown in Figure D.
- Click Send when the message is completed. The recipient will open the mail and the attachment as usual. Remember, the recipient must have Snapshot to view the attached file. When the latter is the case, opening the attachment automatically displays the file in Snapshot.
|Select the Snapshot Format option.|
|The user has to fill in a little information to complete the e-mail message.|
Automating the process
Use the SendObject method to automate the process for your clients. This method allows them to select a report and click a button while your code creates the appropriate snapshot file and attaches the newly created file to an e-mail message. In this next section, you'll create a simple form that displays all the reports in an application.
To begin, open a blank form and add a list box and a command button. Then, refer to Table A to set the appropriate form and control properties. Add the code in either Listing A or Listing B, depending on the version of Access you're working with; add Listing C to the form's module and name the form frmSendSnapshotReport.
Once you've completed and saved the form, switch it to Form View, as shown in Figure E. Both Load events display a list of reports. The Access 97 code uses the Reports collection and Access 2000 and later code uses the AllReports collection.
|Use a form similar to this to create and e-mail a snapshot file.|
Select the Catalogs report from the list box, and then click the Send Report button. Doing so executes the SendObject method, which creates a snapshot file version of the report you selected and then attaches the snapshot file to an e-mail message. At this point, the user fills in the missing information and clicks Send. The Click event contains a small amount of error-handling. Specifically, if the report's data source is missing, the event displays a message box instead of producing a run-time error.
If the snapshot file already exists, use SendObject in the form:
DoCmd.SendObject acSendReport, snpname, acFormatSNP, , , , , True
where snpname is the name of the existing snapshot file you want to attach to the e-mail message.
To implement this simple technique for sending snapshot forms, you may need to reconfigure your mail client. If you're required to log on (in a user profile situation), this technique won't work. In addition, it's been determined that Snapshot could leave a system vulnerable to hacker attacks. For more information, review Security Bulletin MS03-038.
The above example is very simple on purpose, and it requests input from your client, which you might want to avoid. When that's the case, use the SendObject method in the form:
DoCmd.SendObjectobjecttype, objectname, outputformat, to, cc, bcc, subject, messagetext, editmessage, templatefile
whereeditmessage determines whether SendObject launches your mail client. The default is True, which launches the application. A False setting inhibits the client. Be sure to solicit all the necessary information from the user in Access and pass the arguments accordingly.
Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.