Microsoft KB Archive/231797

= How to fax from Microsoft Access by using the SendObject command in Access 2000 =

Article ID: 231797

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q231797





For a Microsoft Access 97 version of this article, see 145787.



For a Microsoft Access 2002 version of this article, see 299016.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

Advanced: Requires expert coding, interoperability, and multiuser skills.

IN THIS TASK
SUMMARY
 * Outlook Email Security
 * Using the SendObject Method
 * Creating a Macro
 * Creating a Visual Basic Procedure

REFERENCES



SUMMARY
This article shows you how to create a macro and a Visual Basic procedure to fax a report from Microsoft Access. The examples assume that you have Microsoft Outlook, Microsoft Fax, and a fax modem installed and that they are functioning.

back to the top

Outlook Email Security
The following code may not work properly if you have installed the Outlook E-mail Security Update. For additional information about this update, please see one of the following articles in the Microsoft Knowledge Base, depending on which version of Outlook you have:

262631 OL2000: Information About the Outlook E-mail Security Update

262617 OL98: Information About the Outlook E-mail Security Update

If your fax does not appear to have proper formatting, you may want to change your default e-mail editor to Microsoft Word. For more information about the Outlook 2002 e-mail security features and how those features can affect custom solutions, click the following article number to view the article in the Microsoft Knowledge Base:

290500 Description of the developer-related e-mail security features in Outlook 2002

back to the top

Using the SendObject Method
The following examples use the sample database Northwind.mdb to show you how to create a macro and a Visual Basic procedure to fax a report using Microsoft Fax. However, you can also use an Access project (.adp) file for faxing information.

When you use the SendObject method within Microsoft Access, you must have a messaging application (for example, Microsoft Outlook), that supports the Microsoft Mail Applications Programming Interface or MAPI.

If Outlook is running at the time you attempt to run the macro or code, you may receive an message similar to:

The file C:\Windows\Application Data\Microsoft\Outlook\Outlook.ost is in use and could not be accessed. Close any application that is using this file, and then try again.

If you see this message, close Outlook and run the code again.

If you have an electronic mail application that uses the Vendor Independent Mail (VIM) protocol and have installed and set up the dynamic-link library (Mapivim.dll) that converts MAPI mail messages to the VIM protocol, you can send Microsoft Access objects to the VIM mail application.

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

back to the top

Creating a Macro
This example uses the SendObject action to fax the Catalog report to a single fax number.  Open the sample database Northwind.mdb. Open the Catalog report in Design view. On the File menu, click Page Setup. In the Page Setup dialog box, click the Page tab. In the Printer for Catalog option group, click Use Specific Printer, and then click the Printer button. In the Name list, select Microsoft Fax, and then click OK.</li> In the Page Setup dialog box, click OK.</li> Save the Catalog report and close it.</li>  Create the following macro named SendFax: <pre class="fixed_text">   Macro Name   Action SendFax     SendObject

Action Arguments Object Type: Report Object Name: Catalog Output Format: Rich Text Format To: [Fax: +1 (###) ###-####] (where (###) ###-#### is the fax number) NOTE: You do not need to include the hyphen "-" for this to work.

</li> Run the macro to fax the report.</li></ol>

back to the top

Creating a Visual Basic Procedure
NOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.

This example shows you how to fax the Invoice report to each customer in the Customers table. <ol> Open the sample database Northwind.mdb.</li> Open the Invoice report in Design view.</li> On the File menu, click Page Setup.</li> In the Page Setup dialog box, click the Page tab.</li> In the Printer For Invoice option group, click Use Specific Printer, and then click the Printer button.</li> In the Name list, select Microsoft Fax, and then click OK.</li> In the Page Setup dialog box, click OK.</li>  Set the OnOpen property of the report to the following event procedure: Me.Filter = strInvoiceWhere </li> Save the report and close it.</li> In the Database window, click Modules, and then click New.</li>  Type or paste the following code into the module.NOTE: If you plan to change this example and place the code behind a form, leave the line "Public strInvoiceWhere As String" in a standard module. Option Explicit

Public strInvoiceWhere As String '**************************************************************** 'This function will walk through the Customers table and fax the 'Invoice report, which is filtered by the CustomerID field using 'MS Fax through the MS Access SendObject. ' 'This function assumes the Invoice report has the default printer 'set to MS Fax and the MS Fax driver is installed correctly. '**************************************************************** Function FaxInvoices Dim dbsNorthwind As DAO.Database Dim rstCustomers As DAO.Recordset

Set dbsNorthwind = CurrentDb Set rstCustomers = dbsNorthwind.OpenRecordset("Customers", _       dbOpenDynaset)

If MsgBox("Do you want to fax invoices" & Chr(13) & _       "to all customers using Microsoft Fax?", 4) = 6 Then With rstCustomers Do Until .EOF 'Create the Invoice report Filter 'used by the Report_Open event. strInvoiceWhere = "[CustomerID] = '" & ![CustomerID] & "'" DoCmd.SendObject acReport, "Invoice", acFormatRTF, _ "[fax: " & ![Fax] & "]",, , , , False .MoveNext Loop End With End If

rstCustomers.Close End Function </li> <li> To test this function, type the following line in the Immediate window, and then press ENTER: ? FaxInvoices </li></ol>

To improve performance, you can choose to delay faxing until an appropriate time, and you can also change the rendering engine. Rich Text Format (RTF) messages sent to Microsoft Fax need to be rendered. The rendering process uses the application associated with .rtf documents. If, for example, you have installed Microsoft Word 2000, that is the rendering application. Microsoft WordPad is a smaller and faster application. If you want to send many fax documents, you might consider changing the .rtf association from Microsoft Word 2000 to WordPad.

To change the association for .rtf documents to WordPad, follow these steps:
 * 1) Click Start and then click Run.
 * 2) In the Open box, type Winfile, and then click OK.
 * 3) In File Manager, on the File menu, click Associate.
 * 4) In the Associate dialog box, under Files with Extension, type rtf.
 * 5) Click Browse
 * 6) Locate WordPad.Exe in C:\Program Files\Accessories, and then click OK.
 * 7) Quit File Manager.

To change the time to send a fax, follow these steps:
 * 1) Click Start, point to Settings, and then click Control Panel.
 * 2) Double-click the Mail And Fax icon.
 * 3) In The following information services are set up in this profile box, select Microsoft Fax, and then click Properties.
 * 4) In the Time to Send box, select Specific Time, type a time in the Time box, and then click OK.
 * 5) Close the Mail And Fax box.

back to the top

<div class="references_section">