johnsmorton
asked on
I want to open a cash drawer connect to an Epson TM-T88 printer from VB in MS Access.
I have written a neat little POS routine for a specialist retail outlet and now want to open a till drawer. I am using Access 2002, XP Pro - the printer is connected to a USB Port (set up by the Epson driver) and the till drawer is connected to the printer. I have installed a Windows driver (for fancy receipts) and a plain text-only driver.
Any thoughts?
Any thoughts?
ASKER
I've tried something similar - but the receipt printer is attached to a USB Port so opening LPT1 doesn't work - how do I open a USB Port?
See http://www.posworld.com/eprecprinvis.html
Option Explicit
Private Sub Form_Load()
'A: Open drawer 1 at 50ms.
'B: Open drawer 1 at 100ms.
'C: Open drawer 1 at 150ms.
'D: Open drawer 1 at 200ms.
'E: Open drawer 1 at 250ms.
'a: Open drawer 2 at 50ms.
'b: Open drawer 2 at 100ms.
'c: Open drawer 2 at 150ms.
'd: Open drawer 2 at 200ms.
'e: Open drawer 2 at 250ms.
OpenCashDrawer "Epson TM-T88", "A"
End Sub
Public Sub OpenCashDrawer(ByVal sDeviceName As String, ByVal sSpecialChar As String)
Dim prnPrinter As Printer
For Each prnPrinter In Printers
Debug.Print Printer.DeviceName
If prnPrinter.DeviceName = sDeviceName Then
Set Printer = prnPrinter
Printer.FontSize = 10 'Set up the control font.
Printer.FontName = "control"
Printer.Print sSpecialChar 'Use special-function character to open the cash drawer.
Printer.EndDoc
Exit For
End If
Next
End Sub
Option Explicit
Private Sub Form_Load()
'A: Open drawer 1 at 50ms.
'B: Open drawer 1 at 100ms.
'C: Open drawer 1 at 150ms.
'D: Open drawer 1 at 200ms.
'E: Open drawer 1 at 250ms.
'a: Open drawer 2 at 50ms.
'b: Open drawer 2 at 100ms.
'c: Open drawer 2 at 150ms.
'd: Open drawer 2 at 200ms.
'e: Open drawer 2 at 250ms.
OpenCashDrawer "Epson TM-T88", "A"
End Sub
Public Sub OpenCashDrawer(ByVal sDeviceName As String, ByVal sSpecialChar As String)
Dim prnPrinter As Printer
For Each prnPrinter In Printers
Debug.Print Printer.DeviceName
If prnPrinter.DeviceName = sDeviceName Then
Set Printer = prnPrinter
Printer.FontSize = 10 'Set up the control font.
Printer.FontName = "control"
Printer.Print sSpecialChar 'Use special-function character to open the cash drawer.
Printer.EndDoc
Exit For
End If
Next
End Sub
ASKER
I know this should work - but I get a compile error "Method or Data Member Not Found" at the Fontname command (and the fontsize). This is really strange as both commands are listed in the VB Help pages! If I type in Printer and dot - an idiot list pops up which does not include fontname and fontsize - it is things like colour and paper bin?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Private Sub PopCashDrawer()
' OPEN LPT1 FOR OUTPUT
Open "lpt1" For Output As #1
' POP CASH DRAWER
' CMD: <BEL>
Print #1, Chr$(7)
' CLOSE THE LPT1 PORT
Close #1
End Sub