Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private Sub cmdSendFax_Click()
Dim rst As Recordset
Dim objSend As Object
Dim sFile As String
Dim dtTemp1 As Date
Dim dtTemp2 As Date
Dim lBillCode As Long
Dim lDateAdd As Long
Dim iCounter As Integer
Dim iMonth As Integer
Dim iDay As Integer
Dim iYear As Integer
Dim iWeekday As Integer
Dim vTemp As Variant
Dim Result
On Error GoTo SendFax_Err
DoCmd.Hourglass True
'Check that the Cover Page file exists
If Me!CoverType = 2 Then 'Cover Page
sFile = Dir(Me!CoverFile)
If sFile & "" = "" Then
DoCmd.Hourglass False
MsgBox "The Cover Page file '" & Me!CoverFile & "' is not found.", _
vbOKOnly, "Schedule WinFax"
GoTo SendFax_Exit
End If
End If
'Check that the Attachment file exists
If Me!AttachType <> 0 Then 'Attachment
sFile = Dir(Me!AttachFile)
If sFile & "" = "" Then
DoCmd.Hourglass False
MsgBox "The Attachment file '" & Me!AttachFile & "' is not found.", _
vbOKOnly, "Schedule WinFax"
GoTo SendFax_Exit
End If
End If
'Set up for submitting faxes to WinFax
Set rst = CurrentDb.OpenRecordset("qryFbBrowseSel", dbOpenForwardOnly)
iCounter = 0
lDateAdd = 0
vTemp = Me!SchedDate
If Not IsNull(vTemp) Then
dtTemp1 = Me!SchedDate
End If
'Go
Do While Not rst.EOF
Result = SysCmd(acSysCmdSetStatus, "WinFax To: " _
& rst!RecipientName & " at " & rst!CompanyName)
Set objSend = CreateObject("WinFax.SDKSend")
objSend.SetClientID ("Client Name") 'Must be first method invoked in order
'to combine AddAttachmentFile and
'SetPrintFromApp
With objSend
'--General:
Result = .ResetGeneralSettings
'Result = .RemoveAllRecipients
'Result = .SetPreviewFax(0)
'--Scheduling:
iCounter = iCounter + 1
If Me!SchedHoldYn = True Then
Result = .SetHold(1) 'Overridden by SetDate/SetTime
Else
Result = .SetHold(0)
End If
If Me!SchedOffPeakYn = True Then
Result = .SetOffPeak(1) '1=Off Peak, 0=Anytime
Else
Result = .SetOffPeak(0)
End If
vTemp = Me!SchedDate
If Not IsNull(vTemp) Then
If iCounter > Me!SchedCount Then
Select Case Me!SchedInterval
Case 1 'Day
lDateAdd = lDateAdd + 1
Case 2 'Week
lDateAdd = lDateAdd + 7
Case 3 'Month
iMonth = Month(Me!SchedDate)
iDay = Day(Me!SchedDate)
iYear = Year(Me!SchedDate)
If iMonth < 12 Then
iMonth = iMonth + 1
Else
iMonth = 1
iYear = iYear + 1
End If
dtTemp2 = CDate(iMonth & "/" & iDay & "/" & iYear)
lDateAdd = DateDiff("d", dtTemp1, dtTemp2)
End Select
iCounter = 1
End If
Result = .SetDate(Format(Me!SchedDate + lDateAdd, "MM/DD/YY"))
End If
vTemp = Me!SchedTime
If Not IsNull(vTemp) Then
Result = .SetTime(Format(Me!SchedTime, "HH:MM:SS"))
End If
'--To:
'Result = .SetCountryCode ("")
Result = .SetAreaCode(AreaCodeFromPhone(rst!FaxNumber) & "")
Result = .SetNumber(NumberFromPhone(rst!FaxNumber) & "")
Result = .SetTo(rst!RecipientName & "")
Result = .SetCompany(rst!CompanyName & "")
'--Billing Code:
'Result = .EnableBillingCodeKeyWords(1)
'lBillCode = lBillCode + 22
'Result = .SetBillingCode(lBillCode)
'Result = .SetKeywords("Fax Blast")
'--Cover Page:
'Result = .SetSubject("")
Result = .SetUseCover(0)
Result = .SetQuickCover(0)
If Me!CoverType <> 0 Then
Result = .SetUseCover(1)
Select Case Me!CoverType
Case 1 'QuickCover
Result = .SetQuickCover(1)
'Result = .SetCoverText(Me!txtFaxCoverText)
Case 2 'Cover Page
Result = .SetQuickCover(0)
Result = .SetCoverFile(Me!CoverFile)
End Select
End If
'--Attachment or Report:
If Me!AttachType <> 0 Then
Select Case Me!AttachType
Case 1 'Fax Attachment
Result = .AddAttachmentFile(Me!AttachFile)
If Result = 1 Then
MsgBox "Couldn't add attachment: " & Me!AttachFile
End If
Case 2 'Application Document
Result = .AddAttachmentFile(Me!AttachFile)
If Result = 1 Then
MsgBox "Couldn't add attachment: " & Me!AttachFile
End If
End Select
End If
Result = .ShowSendScreen(0)
Result = .SetResolution(1) '1=Fine, 0=Standard
Result = .SetDeleteAfterSend(1) '1=Delete, 0=Keep
Result = .ShowCallProgress(0) '1=Show, 0=Hide
'--Add Recipient(s):
Result = .AddRecipient()
If Result = 1 Then
MsgBox "Couldn't add recipient: " & Me!txtFaxContact
GoTo SendFax_Exit
End If
'--Start faxing:
Result = .Send(1) '1=Return EventID, 0=No EventID
Do While .IsReadyToPrint() = 0
DoEvents
Loop
Do While .IsEntryIDReady(0) <> 1
DoEvents
Loop
Result = .Done
Result = .LeaveRunning
Set objSend = Nothing
End With
NextRecipient:
rst.MoveNext
Loop
SendFax_Exit:
On Error Resume Next
rst.Close
Set rst = Nothing
Result = SysCmd(acSysCmdClearStatus)
DoCmd.Hourglass False
Exit Sub
SendFax_Err:
DoCmd.Hourglass False
MsgBox "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description, _
vbOKOnly, "cmdSendNow_Click"
Resume SendFax_Exit
End Sub