Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a buton to "fax"? 1

Status
Not open for further replies.

Np02

Technical User
Mar 14, 2003
21
US
Hi,

like to make a command button in a form of Access be able to fax the report associated to the form. (assume the user's computer has PC phone setup). Ex: After I enter a note in the frm_Note, I have a button to preview the note report (through a qry_Note and preview report). I like to have a button for user to click to fax this note report to somebody, how do I do this?

Appreciate your help.

NP02
 
Hi,

This is directly from Microsoft's Knowledge base website:

INF: How to Fax from Microsoft Access Using SendObject Command

Article ID: Q145787

---------------------------------------------------------------------
The information in this article applies to:

- Microsoft Access versions 7.0, 97
---------------------------------------------------------------------

SUMMARY
=======

Moderate: Requires basic macro, coding, and interoperability skills.

This article describes a technique to use Microsoft Fax to fax reports
from Microsoft Access using a macro or Visual Basic code. The examples
assume that you have Microsoft Exchange, Microsoft Fax, and a fax modem

installed and functioning.

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 file,
RptSampl.exe. For more information about how to obtain this sample file,

please see the following article here in the Microsoft Knowledge Base:

Article ID: Q145777
Title : INF: Microsoft Access Sample Reports Available on MSL (7.0)

This file is a Microsoft Access 7.0 database, which you can open in
Microsoft Access 97 (but do not need to convert to Microsoft Access 97).

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.

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 faxes the Catalog report to a single fax number using the
SendObject action.

1. Open the sample database Northwind.mdb.

2. Open the Catalog report in Design view.

3. On the File menu, click Page Setup.


4. In the Page Setup box, click the Page tab.

5. In the Printer for Catalog box, click Use Specific Printer, and then
click the Printer button.

6. In the Name box, select Microsoft Fax, and then click OK.

7. In the Page Setup box, click OK.

8. Save the Catalog report and close it.

9. Create the following macro named SendFax:

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)

10. Run the macro to fax the report.

Creating a Visual Basic Procedure
---------------------------------

This example shows how to fax the Invoice report to each customer in
the Customers table.


1. Open the sample database Northwind.mdb.

2. Open the Invoice report in Design view.

3. On the File menu, click Page Setup.

4. In the Page Setup Box, click the Page tab.

5. In the Printer for Invoice box, click Use Specific Printer, and then
click the Printer button.

6. In the Name box, select Microsoft Fax, and then click OK.

7. In the Page Setup box, click OK.

8. Set the report's OnOpen property to the following event procedure:

Me.Filter = strInvoiceWhere


9. Save the report and close it.

10. Create a module and type the following in the Declarations section:

Option Explicit
Public strInvoiceWhere As String

11. Type the following procedure:

' ****************************************************************
' 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

12. To test this function, type the following line in the Debug 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 7.0, 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 7.0 to WordPad.

To change the association for .rtf documents to WordPad, follow these
steps:

1. Click the Start button, 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 box, under File 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 the Start button, 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.

REFERENCES
==========

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."

KBCategory: kbprg kbhowto
KBSubcategory: MdlAdrec
Additional reference words: 7.00 97 8.00


Copyright (c) Microsoft Corporation. All rights reserved.

Even though its for Access 97 the functions in other versions (2000, XP) should still work.

HTH,

jbehrne

If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
Hi, jbehrne,

Very good information. Let me figure out first. Please accept a big star from me!

NP02
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top