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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fax from Access

Status
Not open for further replies.

dendic

Programmer
Jan 19, 2003
106
US
Can anybody help me with some code that I can used behind a form to Fax an Invoice based on the displayed invoice.I can't figure out how implement the "where" command within a SendObject command. ex: Print invoice where invoice number = me.invoice number.
 
I may be wrong, but the I think the SendObject method is for sending emails only.

To fax 'an Invoice', try creating a report that shows the invoice, and in Page Setup (while in report design view), specify the 'printer' as your fax program.

Then you can use the OpenReport method (see Access Help) to 'print' the report to your fax.

Max Hugen
Australia
 
Have a look here
I got it to work using that KB. Here's a sample of what the code looked like minus the error handling and some other validations.

Code:
Private Sub btnFax_Click()
Dim stDocName As String
Dim varWhere As Variant
Dim varFaxNum As Variant

stDocName = "yourreport"
varWhere = me.invoiceNumber
varFaxNumber = Dlookup("FaxNumber", "tblCustomers", "CustomerID = " & me.CustomerID) 'set to where you store the fax number- or use a textbox to enter the fax at runtime.

DoCmd.SendObject acReport, stDocName, acFormatSNP, varFaxNum, , , , , False


I don't know if everyone has this experience or not, but this only works for me if Outlook is set as the default mail client. Also, it doesn't send the fax unless you have outlook open at the time.

A couple other thoughts: Make sure you have the default printer to fax on that report. And make sure you have added the Fax Mail transport MAPI in Outlook.
 
Sorry, I didn't mean varFaxNumber on that dlookup line. It should be.

varFaxNum = Dlookup ....etc
 
One last thing. This should be after the dlookup. varFaxNum = "[fax: 1" & varFaxNum & "]"
 
Here is my code when I run a dialog box opens and asks for a fax number and then it starts sending all my invoices instead of the just the one I want.

Dim db As Database
Dim rstCustomers As Recordset
Dim strDefaultPrinter As String
Dim SQLStmt As String
Dim varFaxNum As Variant
Dim stDocName As String
Set db = CurrentDb()
stDocName = "Invoice"
SQLStmt = "select * FROM [customers] WHERE [customer Number] = '" & Me.SOLD_TO_CUSTOMER1 & "';"
Set rstCustomers = db.OpenRecordset(SQLStmt, dbOpenDynaset)
varFaxNum = rstCustomers!Fax
If MsgBox("Do you want to fax this invoice" & Chr(13) & _
"to " & rstCustomers!Company & " ?", 4) = 6 Then
strDefaultPrinter = Application.Printer.DeviceName
Set Application.Printer = Application.Printers("LAN-Fax M1")
DoCmd.OpenReport "invoice", acViewNormal, , "invoice![invoice Number] = '" & Me.Invoice_Number & "'" 'Run the report
DoCmd.SendObject acReport, stDocName, acFormatSNP, varFaxNum, , , , , False
End If
rstCustomers.Close
Set Application.Printer = Application.Printers(strDefaultPrinter)
 
What about this ?
DoCmd.OpenReport "invoice", acView[!]Preview[/!], , "invoice![invoice Number] = '" & Me.Invoice_Number & "'" 'Run the report

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top