fax a report to multiple people

C

chris_quinn26

I have barrowed parts of this code from various places. I can not get
the report to send with the person from the table. Can anybody find
where i have gone wrong. I am eventually going to put a loop on the
recordset to send it to all the people in the list. I really do not
even what to send a coversheet. I would like to just send the report.



Private Sub BUTTON_Run_Elec_RFQ_Click()
'On Error GoTo ErrorHandler
Dim intReturn As Integer
Dim strLastName As String
Dim strcity As String
Dim strMessage As String
Dim strSendTime As String
Dim strSendDate As String
Dim strRecipient As String
Dim lngChannel As Long
Dim strCoverSheet As String
Dim strFax As String
Dim dbs As DAO.Database
Dim dteFax As Date
Dim rst As DAO.Recordset
Dim frm As Access.Form
Dim ctl As Access.Control
Dim strCustomerName As String
Dim strCompany As String
Dim strMessage1 As String
Dim strMessage2 As String
Dim strMessageSubject As String
Dim strTitle As String
Dim strPrompt As String
Dim strWinFaxDir As String
Dim strBody As String
Dim strStreetAddress As String
Dim strlocation As String
Dim strDocName As String

Dim MyRec As Recordset

Set MyRec =
CurrentDb().OpenRecordset("TABLE--Temp_Single_Elec_Fax")

MyRec.MoveFirst


' Dim strDefaultPrinter As String
' ' get current default printer.
' strDefaultPrinter = Application.Printer.DeviceName
' ' switch to printer of your choice:
' Set Application.Printer = Application.Printers("WinFax (Photo
Quality)")




' strDocName = "REPORT--RFQ_Table"
'gstrReportFilter = "QuoteID = " & Me.QuoteID

'Test for required fields
strFax = Nz(MyRec![FAX NUMBER])
Debug.Print "Fax number: " & strFax
If strFax = "" Then
MsgBox "No mailing fax number; can't send fax"
'GoTo ErrorHandlerExit
End If

strStreetAddress = Nz(MyRec![ADDRESS 1]) & Chr(34) &
Nz(MyRec![ADDRESS 2])
If strStreetAddress = "" Then
MsgBox "No street address; can't send fax"
'GoTo ErrorHandlerExit
Else
strlocation = strStreetAddress & " in " &
Nz(MyRec![CITY/STATE/ZIP])
Debug.Print "Location: " & strlocation
End If

strcity = Nz(MyRec![CITY/STATE/ZIP])
strCustomerName = Nz(MyRec![FIRST NAME]) & " " & Nz(MyRec![LAST
NAME])
strCompany = Nz(MyRec![COMPANY NAME])
strMessageSubject = "Request For Quote"
strMessage = Nz(MyRec![Notes])

'Test for required fields
Debug.Print "Fax: " & strFax
strMessageSubject = "Request For Quote"
strBody = Nz(MyRec![Notes])


'Send Fax
If strFax <> "" Then
strCustomerName = Nz(MyRec![FIRST NAME]) & " " & Nz(MyRec![LAST
NAME])
strCompany = Nz(MyRec![COMPANY NAME])
dteFax = Format(Now(), "hh:mm:ss")
strSendDate = Format(dteFax, "mm/dd/yy")


strCoverSheet = WinFaxDir & "COVER\BASIC1.CVP"
Debug.Print "Cover sheet: " & strCoverSheet
Debug.Print strDocName


'***
'Start DDE connection to WinFax.
'Create the link and disable automatic reception in WinFax
lngChannel = DDEInitiate(Application:="FAXMNG32",
topic:="CONTROL")
DDEExecute ChanNum:=lngChannel, Command:="GoIdle"
DDETerminate ChanNum:=lngChannel

'Create a new link with the TRANSMIT topic.
lngChannel = DDEInitiate("FAXMNG32", "TRANSMIT")

'Start DDEPokes to control WinFax.
strRecipient = "recipient(" & Chr$(34) & strFax & Chr$(34) & "," _
& Chr$(34) & strSendTime & Chr$(34) & "," _
& Chr$(34) & strSendDate & Chr$(34) & "," _
& Chr$(34) & strCustomerName & Chr$(34) & "," _
& Chr$(34) & strCompany & Chr$(34) & "," _
& Chr$(34) & strMessageSubject & Chr$(34) & ")"
Debug.Print "Recipient string: " & strRecipient
Debug.Print "Length of recipient string: " & Len(strRecipient)
DDEPoke ChanNum:=lngChannel, Item:="sendfax", Data:=strRecipient

'Specify cover page
DDEPoke ChanNum:=lngChannel, Item:="sendfax", _
Data:="setcoverpage(" & Chr$(34) _
& strCoverSheet & Chr$(34) & ")"
' DoCmd.OpenReport strDocName, acViewNormal

'Send cover sheet text
DDEPoke ChanNum:=lngChannel, Item:="sendfax", _
Data:="fillcoverpage(" & Chr$(34) _
& strBody & Chr$(34) & ")"

'Show send screen
DDEPoke ChanNum:=lngChannel, Item:="sendfax", _
Data:="showsendscreen(" & Chr$(34) _
& "0" & Chr$(34) & ")"

'Set resolution
DDEPoke ChanNum:=lngChannel, Item:="sendfax", _
Data:="resolution(" & Chr$(34) _
& "HIGH" & Chr$(34) & ")"

'Send the fax
DDEPoke ChanNum:=lngChannel, Item:="sendfax", Data:="SendfaxUI"
DDETerminate ChanNum:=lngChannel
lngChannel = DDEInitiate(Application:="FAXMNG32",
topic:="CONTROL")
DDEExecute ChanNum:=lngChannel, Command:="GoActive"
DDETerminate ChanNum:=lngChannel
End If


Set Application.Printer = Application.Printers(strDefaul­tPrinter)


ErrorHandlerExit:
DoCmd.Close objecttype:=acForm, objectname:=Me.Name
Exit Sub

ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & _
Err.Description
Resume ErrorHandlerExit
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top