Winfax from Access

A

Alex

We have a WinFax that is working with Access 2003. Everything was fine till
very recently the WinFax started to work incorrectly. We reinstall WinFax on
a new computer so it’s working itself without Access.
From Access it should print an order and fax it switching a default printer
after printing to a fax and back. But, somehow if initially regular printer
is default it’s printing two pages instead of doing one printing and one
faxing. And if a fax is set up as default it’s faxing two pages instead of
one printing and one faxing.

Here is a code we’re using in Access. Could anybody advise how we could fix
it.

Sorry, I cannot post it on Access forum as it's blocked now from my work
computer.

Thanks

Private Sub Command43_Click()
On Error GoTo Err_Command43_Click
Dim supid As Integer
Dim r
Dim DocName As String
If vbYes = MsgBox("Do you want to print PO:" & [Order ID] & "?", vbYesNo,
"Purchase Orders") Then
DocName = "Purchase Order"
DoCmd.OpenReport DocName, A_NORMAL, , "[Order ID]=" & [Order ID]
End If
If vbYes = MsgBox("Do you want to fax PO:" & [Order ID] & "?", vbYesNo,
"Purchase Orders") Then
Dim orderid As Long
orderid = [Order ID]
supid = [Customer ID]
r = Facsimile(supid, orderid)
End If

Exit_Command43_Click:
Exit Sub

Err_Command43_Click:
MsgBox Error$
Resume Exit_Command43_Click
End Sub

Function Facsimile(suplierid As Integer, orderid As Long)
Dim cbuffer As String
Dim rc As Long
Dim wp As Integer
Const DDE_ERROR = 282
Dim channum As Long
Dim company$
Dim contact$
Dim faxnum$
Dim rssupliers As Recordset
Set rssupliers = db.OpenRecordset("select [company Name], [contact
name],[contact Title], fax from customers where [customer ID]=" & suplierid)
If rssupliers.EOF Then
MsgBox "No supplier with ID " & SupplierID, vbExclamation + vbOKOnly, "Fax"
rssupliers.Close
Exit Function
End If
company$ = rssupliers(0)
contact$ = rssupliers(1)
faxnum$ = rssupliers(3)
rssupliers.Close
If Dir("c:\Program files\Symantec\Winfax\Faxmng32.exe") = "" Then
MsgBox "WinFax is not installed on this machine!", vbExclamation, "Sales
Orders"
Exit Function
End If
cbuffer = String$(255, 32)
rc = GetProfileString("windows", "device", "", cbuffer, Len(cbuffer))
If rc = 0 Then
MsgBox "The application can not read the default printer!",
vbExclamation, "Sales Orders"
End If
wp = WriteProfileString("windows", "device", "WinFax,winspool,Ne00:")
If wp = 0 Then
MsgBox "WinFax can not be set up as printer!" & Chr(10) & Chr(13) &
"Contact your system administrator.", vbExclamation, "Sales Orders"
Exit Function
End If
SendTime$ = Time
SendDate$ = Format$(Date, "mm/dd/yy")
resumefax:
channum = DDEInitiate("FAXMNG32", "TRANSMIT")
DDEPoke channum, "SendFax", "recipient(""" + faxnum$ + """ + CHR$(44) +
Chr$(44) + chr$(44) + """ + contact + """ + Chr$(44) + """ + custname + """)"
DoCmd.OpenReport "Fax Order", A_NORMAL, , "[Order ID]=" & orderid
If rc <> 0 Then
wp = WriteProfileString("windows", "device", cbuffer)
If wp = 0 Then
MsgBox "Unable to set the default printer. Please set the default
printer with Print Manager.", MB_ICONSTOP, "FAX"
Exit Function
End If
End If
facsimile_exit:
Facsimile = 0
Exit Function

facsimile_Err:
Select Case Err
Case DDE_ERROR
TEMP = Shell("c:\Winfax\faxMNG.exe", 6)
Resume resumefax
Case 3021
DoCmd.Hourglass False
Case Else
DoCmd.Hourglass False
MsgBox Error$ & str$(Err)
End Select
MsgBox "Please check you default printer!", vbExclamation, "Fax"
Resume facsimile_exit
End Function
 

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