Public Sub CmdCOpen_Click() On Error GoTo Err_Handler Dim Cancel As Integer Dim intPortID As Integer ' Ex. 1, 2, 3, 4 for COM1 - COM4 Dim lngStatus As Long Dim strError As String If IsNull(Me.CboInvoices) Then Beep MsgBox "Please select the invoice number to sign off now", vbOKOnly, "Invoice number not selected" Cancel = True Exit Sub ElseIf (DLookup("InvoiceNumber", "tblDreceipts", "INVID =" & [CboInvoices]) <> "") Then Beep MsgBox "Please note that this invoice is already signed by the gadget, select another one", vbOKOnly, "Try again" Cancel = True Exit Sub End If intPortID = Forms!frmLogin!txtFinComPort.value ‘ COM 4 ' Initialize Communications lngStatus = CommOpen(intPortID, "COM" & CStr(intPortID), "baud=115200 parity=N data=8 stop=1") If lngStatus <> 0 Then ' Handle error. MsgBox Err.Number & Err.Description, vbExclamation, "Error" Application.Quit ElseIf lngStatus = 0 Then Beep MsgBox "Please note that the port is open now", vbOKOnly, "Start processing the invoice details now" End If ' Set modem control lines. lngStatus = CommSetLine(intPortID, LINE_RTS, True) lngStatus = CommSetLine(intPortID, LINE_DTR, True) Call CmdCwrite_Click Call SleepTest Call CmdCread_Click Call CmdClose_Click Me.CboEsdInvoices.Requery Exit Sub
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.