- This topic is empty.
-
AuthorPosts
-
June 11, 2007 at 5:31 pm #2740
aldol
MemberWe have a WinFax that is working with Access. 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. 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 IfExit_Command43_Click:
Exit SubErr_Command43_Click:
MsgBox Error$
Resume Exit_Command43_Click
End SubFunction 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 filesSymantecWinfaxFaxmng32.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 Functionfacsimile_Err:
Select Case Err
Case DDE_ERROR
TEMP = Shell(“c:WinfaxfaxMNG.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 FunctionJune 11, 2007 at 6:26 pm #4696Administrator
KeymasterI believe the problem may be related to using “hard coding” of the winfax printer port, ne00: there is no guarantee that this is the proper port, and you should have code that reads the port before you write the port as the current printer.
cbuffer = String$(255, 32)
rc = GetProfileString("windows", "device", "", cbuffer, Len(cbuffer))
If rc = 0 Then
June 11, 2007 at 11:29 pm #4697aldol
MemberThank you very much, Moderator.
Could you please advise how I could find a proper fax port if initially it was a regular printer and we want to make a fax the default one and find what’s a proper port for this?
” -read the proper port names from the registry (no assuming winfax is in a specific port) “
Best Regards
June 12, 2007 at 12:37 am #4698Administrator
Keymasterit depends on the version of Access you’re using. if its 2002 or later, I believe the printer object does all this for you, so you don’t have to worry about ports etc.
however, I don’t know if this is specific to the problem you’re experiencing without further information.
-
AuthorPosts
- You must be logged in to reply to this topic.