Distributing Reports Using Snapshots


Distributing Reports Using Snapshots

You can make Access reports available to others via the Internet and e-mail by using snapshot files. As such, snapshots allow a much wider audience for your reports, including users without Access and those not connected to your local area network (LAN). A workstation must have a Snapshot viewer to view a snapshot of an Access report. The viewer application, which ships with Access 2003 and is available as a free standalone application, includes an ActiveX control for use in Web browsers that support it, such as Internet Explorer 4 or later. Users can also view snapshots on remote computers without browsers capable of working with ActiveX controls. For example, a Netscape browser can download snapshot files over an HTTP connection. Netscape users can then use the standalone version of the Snapshot viewer with the saved file on their local hard disk.

Note  

The Web site http://www.ProgrammingMSAccess.com maintains an online tutorial on using and deploying Access snapshot solutions. The tutorial includes an overview of snapshots, step-by-step instructions for their use, and several samples that illustrate the performance of the Snapshot viewer in different contexts. If you use an older version of Access, or if you don't even use Access or Internet Explorer, you can still use Access snapshots. The tutorial explains how. The URL for downloading the free viewer is http://www.microsoft.com/accessdev/prodinfo/snapshot.htm .

Creating a Snapshot

You can create a snapshot for a report by selecting the report in the Database window and choosing File, Export. From the Save As Type drop-down list, select Snapshot Format. This enters the selected report name as the name of the snapshot file in the Export Report dialog box. (See Figure 6-22.) In the Save In drop-down list, designate a location for your snapshot file. Figure 6-22 shows the report you saw in Figure 6-5 being saved to a folder named pma11 that contains the intranet site for this book on my local computer. You will, of course, need to change this folder name for your computing environment. Clicking Export in the dialog box in Figure 6-22 opens a progress dialog box and, after the file has been saved, opens it in the Snapshot viewer. The file resides on the server and has an .snp extension.

click to expand
Figure 6.22: Creating a snapshot file manually.

You can also create a snapshot file for a folder on a LAN programmatically. The trick is to use the OutputTo method for the DoCmd object. When using OutputTo for this purpose, four arguments are required. You can list these arguments immediately after the command in the following order: Object Type , Object Name , Output Format , and Output File . The Object Type and Output Format arguments are always the same when generating a snapshot file. The Object Type must refer to a report; use the acOutputReport intrinsic constant to denote a report. Assign the string " Snapshot Format " to the Output Format argument. Use the remaining two arguments to specify the report name as well as the path and file name for your snapshot file.

The following pair of procedures illustrates the syntax for the Output method when saving a report as snapshot file. The sample saves rptChart as a snapshot in the pma11 intranet site on my local computer. The path to the Web site is C:\inetpub\ wwwroot \pma11. The first procedure assigns the report name, as well as the path and file names for the snapshot, to string variables . If the file exists already, the procedure silently overwrites the prior version. The second procedure invokes the OutputTo method with the arguments passed to it and the two fixed arguments.

 SubCallCreateASnapShotReport()  Dimstr1AsString Dimstr2AsString     'Assignstringvaluesforreportnameand 'pathforsavingsnapshot(.snp)file str1= "rptChart" str2= "C:\inetpub\wwwroot\pma11\rptChart.snp"     'Callprocedureforgeneratingsnapshot CreateASnapShotReportstr1,str2     EndSub     SubCreateASnapShotReport(strReportNameAsString,_ strSnapShotPathFileAsString)      'InvokeOutputTomethodwithargumentsfor 'creatingasnapshotonaLAN DoCmd.OutputToacOutputReport,_ strReportName,_  "SnapShotFormat",_ strSnapShotPathFile EndSub 

Viewing a Snapshot

A workstation running Internet Explorer 4 or later that has the Snapshot viewer installed can open the snapshot file. Figure 6-23 shows the report in Internet Explorer 6. The viewer appears to be inside the browser, but it actually takes control of the browser. Special navigator controls on a bar at the bottom of the ActiveX control enable navigation through the pages of a report. The same navigator bar also includes a button for printing. (This is because the control disables the native browser printing functionality.)

Note  

With its initial standard security setting, an Internet Explorer 6 browser prompts whether to open or save a snapshot file locally, because the snapshot file is an ActiveX control that can run a program. To view the report, users must choose to open or save the file.

Notice the close correspondence between the browser image in Figure 6-23 and the original report shown in Figure 6-5. This level of correspondence does not occur when you export to the HTML Documents format. In fact, the HTML Documents format cannot handle Access charts in reports. However, the Snapshot format accommodates both text and graphic content. In addition, exporting to HTML does not provide the built-in navigation functionality that the Snapshot viewer control offers.

click to expand
Figure 6.23: An Access chart-based report viewed from Internet Explorer 6.

The Snapshot viewer control lets you embed an Access report on a Web page along with other content. The following HTML excerpt shows the body of a Web page containing <h3> and <h4> tags before the object reference to the Snapshot viewer control. The full file is available with the support materials for this chapter. The text blocks preceding the control explain how to download the viewer if the report does not appear, and they offer a hyperlink to a site from which you can download the viewer. The instructions also explain how to view the report in Netscape Navigator. Of course you need to update the SnapshotPath parameter to the URL for the snapshot file that you want to show.

 <body> <H3>SnapshotSamplepage</H3> <H4>IfyouhaveanInternetExplorer3orlaterbrowserbut cannotseethe report below,download and install the    <ahref="http://www.microsoft.com/accessdev/prodinfo/snapdl.htm"> MicrosoftAccessSnapshotviewer</a>. Then,refreshthepage.NetscapeNavigatoruserswillnotevensee the report container in their browsers,buttheycanopenthereport outsidetheirbrowserusingthesameSnapshotviewerjustmentioned. Netscapeuserscandownloadthesnapshotfilefrom aWebserverthroughhttpprotocoltotheirworkstation.</H4> <OBJECTID="SnapshotViewer" WIDTH=640HEIGHT=480 CLASSID="CLSID:F0E42D60-368C-11D0-AD81-00A0C90DC8D9"> <PARAMNAME="_ExtentX" VALUE="16722"> <PARAMNAME="_ExtentY" VALUE="11774"> <PARAMNAME="_Version" VALUE="65536"> <PARAMNAME="SnapshotPath" VALUE="http://cabsony1/pma11/rptChart.snp"> <PARAMNAME="Zoom" VALUE="0"> <PARAMNAME="AllowContextMenu" VALUE="-1"> <PARAMNAME="ShowNavigationButtons" VALUE="-1"> </OBJECT> </body> 

Other Uses for Snapshots

Snapshot files based on Access reports have many other uses. For example, you can electronically mail a report as an attached snapshot file by right-clicking on the report in the Database window and choosing Send To and then Mail Recipient from the shortcut menu. Remember to include in your message a link to the download site for the Snapshot viewer if there is any possibility the client does not have the Snapshot viewer already installed.

You can also use the DoCmd object's OutputTo and SendObject methods to automate the conversion and copying of snapshot files to an intranet site or to e-mail recipients. The "Mailing Snapshots" section later in this chapter includes a code sample that can e-mail multiple files to one or more recipients. The "Creating a Snapshot" section presents the syntax and a code sample for using the OutputTo method to generate and save a snapshot file.




Programming Microsoft Office Access 2003
Programming MicrosoftВ® Office Access 2003 (Core Reference) (Pro-Developer)
ISBN: 0735619425
EAN: 2147483647
Year: 2006
Pages: 144
Authors: Rick Dobson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net