ACC2000: How to Fax from Microsoft Access Using SendObject Command
ID: Q231797
|
The information in this article applies to:
This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).
Advanced: Requires expert coding, interoperability, and multiuser skills.
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 Exchange, Microsoft Fax, and a fax modem installed and that they are functioning.
NOTE: If your fax does not appear to have proper formatting, you may want to change your default e-mail editor to Microsoft Word.
MORE INFORMATION
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.
NOTE: When you use the SendObject method within Microsoft Access, you must have a messaging application (for example, Microsoft Exchange), that supports the Microsoft Mail Applications Programming Interface or MAPI.
NOTE: 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: Following the steps in this example will modify the sample
database Northwind.mdb. You may want to back up the Northwind.mdb file
and perform these steps on a copy of the database.
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.
- In the Page Setup dialog box, click OK.
- Save the Catalog report and 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: ###-####] (where ###-#### is the fax number)
- Run the macro to fax the report.
Creating a Visual Basic Procedure
The sample code in this article uses Microsoft Data Access
Objects. For this code to run properly, you need to reference
the Microsoft DAO 3.6 Object Library.
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 the Printer button.
- In the Name list, select 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 close it.
- In the Database window, click Modules, and then click New.
- 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
- 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 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:
- Click Start and then click Run.
- In the Open box, type Winfile, and then click OK.
- In File Manager, on the File menu, click Associate...
- In the Associate dialog box, under Files with Extension, type rtf.
- 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 the Mail And Fax icon.
- In The following information services are set up in this profile listbox, select Microsoft Fax, and then click Properties.
- In the Time to Send box, select Specific Time, type a time in the Time box, and then click OK.
- Close the Mail And Fax box.
REFERENCESFor 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.
Additional query words:
Keywords : kbprg kbdta AccCon IntpOle
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto
|