Article ID: 299016
Article Last Modified on 10/11/2006
APPLIES TO
- Microsoft Access 2002 Standard Edition
This article was previously published under Q299016
For a Microsoft Access 97 version of this article, see 145787.
For a Microsoft Access 2000 version of this article, see 231797.
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
This article describes 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 working.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. back to the top
Outlook e-mail security
The following code may not work correctly if you have installed the Outlook E-mail Security Update. For additional information about this update for Outlook 2000, click the following article number to view the article in the Microsoft Knowledge Base:
262631 OL2000: Information About the Outlook E-mail Security Update
For additional information about this update for Outlook 98, click the following article number to view the article in the Microsoft Knowledge Base:
262617 OL98: Information About the Outlook E-mail Security Update
If your fax does not have correct 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
Using the SendObject method
The examples that are used in this article refer to the sample database Northwind.mdb. The examples show you how to create a macro and a Visual Basic procedure to fax a report by using Microsoft Fax. However, you can also use an Access project (.adp) file for faxing information.
When you use the SendObject method in Microsoft Access, you must have a messaging application, such as Microsoft Outlook, that supports the Microsoft Mail Applications Programming Interface, also known as MAPI.
If Microsoft Outlook 2002 is installed on your computer, and you try to run the macro or the code to fax a report by using Microsoft Fax, you may not be able to fax the report successfully.
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
319820 OL2002: You Receive an NDR When You Use a Simple MAPI Program to Send a Message
If Outlook is running when you try to run the macro or the code, you may receive a message that is similar to the following:
If you receive this message, close Outlook and then run the code again.
If you have an electronic mail application that uses the Vendor Independent Mail (VIM) protocol, you have to install and to setup the dynamic-link library that is named Mapivim.dll. Mapivim.dll converts MAPI mail messages to the VIM protocol. Now 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 Printer.
- In the Name list, click Microsoft Fax, and then click OK.
- In the Page Setup dialog box, click OK.
- Save the Catalog report, and then close it.
Create the following macro named SendFax:
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 have to include the hyphen in the previous fax number for this to work.
- Run the macro to fax the report.
Creating a Visual Basic procedure
Note The sample code in this article uses Microsoft Data Access Objects. For this code to run correctly, 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.
- Open the sample database Northwind.mdb.
- Open the Invoice 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 Invoice option group, click Use Specific Printer, and then click Printer.
- In the Name list, click Microsoft Fax, and then click OK.
- In the Page Setup dialog box, click OK.
Set the OnOpen property of the report to the following event procedure:
Me.Filter = strInvoiceWhere
- Save the report, and then close it.
- In the Database window, click Modules, and then click New.
Put the following code in the module.
Note If you plan to change this example and put 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 that is filtered by the CustomerID field by using 'MS Fax through the MS Access SendObject. ' 'This function assumes that the Invoice report has the default printer 'set to MS Fax, and that 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 who are using Microsoft Fax?", 4) = 6 Then With rstCustomers Do Until .EOF 'Create the Invoice report Filter 'that is 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
To test this function, type the following line in the Immediate window, and then press ENTER:
? FaxInvoices()
To improve performance, you can choose to delay faxing to a time that is less busy. You can also change the rendering engine. Rich Text Format (RTF) messages sent to Microsoft Fax have to be rendered. The rendering process uses the application that is associated with .rtf documents. For example, you may have installed Microsoft Word 2000. That means that Microsoft Word 2000 is the rendering application. Microsoft WordPad is a smaller and faster application. If you want to send many fax documents, you can change the .rtf association from Microsoft Word 2000 to WordPad.
To change the association for .rtf documents to WordPad, follow these steps:
- Click Start, click Run, type Winfile, and then click OK.
- On the File menu, click Associate in File Manager.
- In the Associate dialog box, type rtf under Files with Extension.
- Click Browse.
- Locate WordPad.exe in C:\Program Files\Accessories, and then click OK.
- Quit File Manager.
To change the time to send a fax, follow these steps:
- Click Start, point to Settings, and then click Control Panel.
- Double-click Mail And Fax.
- In The following information services are set up in this profile box, click Microsoft Fax, and then click Properties.
- In the Time to Send box, click Specific Time, type a time in the Time box, and then click OK.
- Close the Mail And Fax box.
REFERENCES
This article describes a technique that is demonstrated in the sample file that is named RptSmp00.exe. For additional information about how to obtain this sample file, click the following article number to view the article in the Microsoft Knowledge Base:
231851 The "Access 2000 sample: report topics database available in Download Center
For additional information about how Outlook 2000 may be affected by the Outlook E-mail Security Update, click the following article number to view the article in the Microsoft Knowledge Base:
262634 OL2000: Known Issues with the Outlook E-mail Security Update
For additional information about how Outlook 98 may be affected by the Outlook E-mail Security Update, click the following article number to view the article in the Microsoft Knowledge Base:
262618 OL98: Known Issues with the Outlook E-mail Security Update
For more information about SendObject, click Microsoft Visual Basic Help on the Help menu, type SendObject action in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.
For more information about OutputTo, click Microsoft Visual Basic Help on the Help menu, type OutputTo in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.
For more information about FindFirst, click Microsoft Visual Basic Help on the Help menu, type FindFirst Method in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.
back to the top
Additional query words: OfficeKBHowTo inf
Keywords: kbhowtomaster kbprogramming KB299016