ACC: How to Fax from Microsoft Access Using SendObject CommandID: Q145787
|
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
functioning.
NOTE: If your fax does not appear to have proper formatting, you may want
to change your default email editor to Microsoft Word.
This article assumes that you are familiar with Visual Basic for
Applications and with creating Microsoft Access applications using the
programming tools provided with Microsoft Access. For more information
about Visual Basic for Applications, please refer to your version of the
"Building Applications with Microsoft Access" manual.
NOTE: This article explains a technique demonstrated in the sample
files, RptSampl.exe (for Microsoft Access for Windows 95 version 7.0)
and RptSmp97.exe (for Microsoft Access 97). For information about how
to obtain these sample files, please see the following articles in the
Microsoft Knowledge Base:
Q145777 ACC95: Microsoft Access Sample Reports Available on MSL
Q175072 ACC97: Microsoft Access 97 Sample Reports Available on MSL
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.
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.
Macro Name Action
------------------------
SendFax SendObject
SendFax Actions
-------------------------------------------------------------------
SendObject
Type : Report
Object Name : Catalog
Output Format: Rich Text Format
To: : [Fax: ###-####] (where ###-#### is the fax number)
Me.Filter = strInvoiceWhere
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 DATABASE
Dim rstCustomers As 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
? FaxInvoices()
For more information about SendObject, search the Help Index for
"SendObject Action."
For more information about OutputTo, search the Help Index for
"OutputTo."
For more information about FindFirst, search the Help Index for
"FindFirst Method."
Additional query words:
Keywords : kbprg IntpOle
Version : WINDOWS:7.0,97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: August 5, 1999