I want to open a cash drawer connect to an Epson TM-T88 printer from VB in MS Access.

Posted on 2004-11-13
Last Modified: 2012-05-05
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?
Question by:johnsmorton
    LVL 22

    Expert Comment

    Try this sub:

    Private Sub PopCashDrawer()
       Open "lpt1" For Output As #1
       ' CMD:  <BEL>
       Print #1, Chr$(7)
       Close #1
    End Sub

    Author Comment

    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?
    LVL 22

    Expert Comment


    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.
             Exit For
          End If

    End Sub


    Author Comment

    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?
    LVL 22

    Accepted Solution

    Try running this from Vb6 instead of Access2000. All the Printer.Font properties appear here (Name, Size, Bold, etc.) and I get no compile errors. Im using XP-SP1, VB6-SP5.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now