How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask Jennifer French Your Own Question
Jennifer French
Jennifer French, Computer Support Specialist
Category: Computer
Satisfied Customers: 132
Experience:  Owner at Down Home Technical Solutions
95132829
Type Your Computer Question Here...
Jennifer French is online now
A new question is answered every 9 seconds

How can I code in access so I can open the cash drawer with

Customer Question

How can I code in access so I can open the cash drawer with out using the printer?
Submitted: 1 year ago.
Category: Computer
Customer: replied 1 year ago.
can anyone help me with my question?
Customer: replied 1 year ago.
It will be possible to get an answer today? It is 45min since I first sent my question
Expert:  Jennifer French replied 1 year ago.

Sorry about the wait. What kind of printer do you have?

Expert:  Jennifer French replied 1 year ago.

I'm going to take a shot in the dark here. This is just a basic coding for cash drawers in MS Access.

Dim intCOM1 As Integer
Dim strCommandCodes As String

strCommandCodes = Chr$(16) & Chr$(20) & Chr$(1) & Chr$(0) & Chr$(2) ' using connector pin 2
' strCommandCodes = Chr$(16) & Chr$(20) & Chr$(1) & Chr$(1) & Chr$(2) ' using connector pin 5

intCOM1 = FreeFile

Open "Lpt1" For Binary As #intCOM1 'COM1
Put #intCOM1, , strCommandCodes
Close intCOM1

If you are printing using a DOS program, make sure you use this as well.

net use lptx: \\printserver\sharename /persistent:yes

Please respond and let us know if you were able to code this correctly.

Customer: replied 1 year ago.
no I am using access, I am working with POS and my printer is an Epson TM88V
and the character to open the cash drawer are 7 112 48 55 121
Expert:  Jennifer French replied 1 year ago.

OK. Give me just a moment.

Expert:  Jennifer French replied 1 year ago.

What version of Access are you using?

Customer: replied 1 year ago.
once I sent a receive to print the printer will open the cash drawer but we don't need to print a receive all the time so I need to be able to open the cash drawer whenever I press the CASH button on my form
Customer: replied 1 year ago.
Access 2007
Expert:  Jennifer French replied 1 year ago.

Thank you. Give me a moment. Come heck or high water, I'm gonna find an answer that will work.

Expert:  Jennifer French replied 1 year ago.

Have you tried the codes that you provided already?

Customer: replied 1 year ago.
I am trying it now
Expert:  Jennifer French replied 1 year ago.

Ok. I'm here. Just let me know.

Customer: replied 1 year ago.
It doesn't work I got a file error
Expert:  Jennifer French replied 1 year ago.

Ok. Was the first number 27 or 7?

This is the set of codes that I have. 27,112,48,55,121

Customer: replied 1 year ago.
file not found on: Open "Lpt1" For Binary As #intCOM1 'COM1
Customer: replied 1 year ago.
27
Customer: replied 1 year ago.
can we get connect on remote so you could see my db
Expert:  Jennifer French replied 1 year ago.

At the moment, I don't have the access to do that. I do know that you have the correct codes and are doing everything correctly. I believe perhaps maybe there is a driver issue or maybe the cable just needs to be reseated.

Customer: replied 1 year ago.
but it works perfect when I send a receive to print the cash drawer will open
Customer: replied 1 year ago.
Please review the codding I have and let me know if I am missing anything:
Private Sub ComCash_Click()
Me.Paid = "Cash"
DoCmd.SetWarnings (WarningsOff)
DoCmd.RunSQL "UPDATE 005_tbl_Tag_Selected AS A INNER JOIN 005_tbl_Tag_Selected AS B ON A.Tag = B.Tag Set A.Paid = B.Paid WHERE A.Paid Is Null and B.Paid Is Not Null"
DoCmd.Close acForm, "005-01_frm_Pagar", acSaveNo
DoCmd.SetWarnings (WarningsOn)
Dim intCOM1 As Integer
Dim strCommandCodes As StringstrCommandCodes = Chr$(27) & Chr$(112) & Chr$(48) & Chr$(55) & Chr$(121) ' using connector pin 2
strCommandCodes = Chr$(27) & Chr$(112) & Chr$(48) & Chr$(55) & Chr$(121) ' using connector pin 5intCOM1 = FreeFileOpen "Lpt1" For Binary As #intCOM1 'COM1
Put #intCOM1, , strCommandCodes
Close intCOM1DoCmd.OpenForm "Calculator1", acNormal
End Sub
Expert:  Jennifer French replied 1 year ago.

OK. Let me check it out.

Customer: replied 1 year ago.
great
Customer: replied 1 year ago.
any idea is I am doing nothing wrong?
Expert:  Jennifer French replied 1 year ago.

Is this a USB connection?

Customer: replied 1 year ago.
the computer to the printer
Expert:  Jennifer French replied 1 year ago.

The coding looks right actually. I'm trying to find out what would be causing the error when you kick the drawer but not when you print a receipt.

Expert:  Jennifer French replied 1 year ago.

Since you are using USB the LPT1 port won't kick the drawer. Let me see if I can come up with a sub to deter that.

Customer: replied 1 year ago.
Now I assigned your codding to when the forms close and I get a different reason:
new code:
Private Sub Form_Close()
Dim intCOM1 As Integer
Dim strCommandCodes As StringstrCommandCodes = Chr$(27) & Chr$(112) & Chr$(48) & Chr$(55) & Chr$(121) ' using connector pin 2
strCommandCodes = Chr$(27) & Chr$(112) & Chr$(48) & Chr$(55) & Chr$(121) ' using connector pin 5intCOM1 = FreeFileOpen "Lpt1" For Binary As #intCOM1 'COM1
Put #intCOM1, , strCommandCodes
Close intCOM1End Suband I get "your network access was interrupted to continue, close the db & open it again???
Expert:  Jennifer French replied 1 year ago.

You had it right before from what I am seeing. It's an issue with the USB, I'm 99 percent certain.

Customer: replied 1 year ago.
Can you help me to fix it?
Expert:  Jennifer French replied 1 year ago.

Can you issue the command in VB at all?

Expert:  Jennifer French replied 1 year ago.

If you can issue this code in VB6, it will work. It bypasses the USB issue somehow.

sWrittenData = Chr(&H1B) & Chr(&H70) & Chr(0) & Chr(25) & Chr(30)

Customer: replied 1 year ago.
The computer is connected to the printer with a USB but the printer to the cash register with a LAN
Expert:  Jennifer French replied 1 year ago.

Also where it says "End Sub" replace it with "End Function".

Customer: replied 1 year ago.
New code:
Private Sub Form_Close()
Dim intCOM1 As Integer
Dim strCommandCodes As StringsWrittenData = Chr(&H1B) & Chr(&H70) & Chr(0) & Chr(25) & Chr(30)intCOM1 = FreeFileOpen "Lpt1" For Binary As #intCOM1 'COM1
Put #intCOM1, , strCommandCodes
Close intCOM1End SubIs not working
Customer: replied 1 year ago.
Sub by Function still don't work
Expert:  Jennifer French replied 1 year ago.

Keep your original code. But try this. This is just a shot in the dark here.

Option Explicit

Private Type DOCINFO
pDocName As String
pOutputFile As String
pDatatype As String
End Type

Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, ByVal pDefault As Long) As Long
Private Declare Function StartDocPrinter Lib "winspool.drv" Alias "StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pDocInfo As DOCINFO) As Long
Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Private Declare Function WritePrinter Lib "winspool.drv" (ByVal hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, pcWritten As Long) As Long

Public Function OpenCashDrawer()
'Declare Vars
Dim lhPrinter As Long
Dim lReturn As Long
Dim lpcWritten As Long
Dim lDoc As Long
Dim sWrittenData As String
Dim MyDocInfo As DOCINFO
'
'Open connection with rpinter
lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)
If lReturn = 0 Then
MsgBox "The Printer Name you typed wasn't recognized."
Exit Sub
End If
'Set information
MyDocInfo.pDocName = "OPENCASH"
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString
'
'Initiate the document
lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
Call StartPagePrinter(lhPrinter)
'
'Here is your line of code:
sWrittenData = Chr(&H1B) & Chr(&H70) & Chr(0) & Chr(25) & Chr(30)
'
'Write to the printer
lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, Len(sWrittenData), lpcWritten)
'
'Close printer connection
lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
lReturn = ClosePrinter(lhPrinter)
End Function

Private Sub Command1_Click()
'Open the cash drawer when this button is clicked
OpenCashDrawer
End Sub

Customer: replied 1 year ago.
Where should I include all that coding?
Expert:  Jennifer French replied 1 year ago.

In Access where you have your old code. Just try it and see if it works.

Expert:  Jennifer French replied 1 year ago.

This code talks more directly to the printer.

Customer: replied 1 year ago.
Ok but after the first coding you gave me, meaning the first coding follow by this last
Customer: replied 1 year ago.
this : Private Sub Command1_Click()
to where it gets assigned?
Expert:  Jennifer French replied 1 year ago.

Yes. Just make sure you save your original coding in case this doesn't work.

Customer: replied 1 year ago.
it doesn't work
Expert:  Jennifer French replied 1 year ago.

I have done all that I know to do. I would say your best bet would be to contact Epson themselves and see if they have better options. Your coding is good, though.

Expert:  Jennifer French replied 1 year ago.

I can opt-out and see if someone else has any better ideas but if I were in your shoes, I'd call the people that made the printer.

Customer: replied 1 year ago.
Ok I will call the Epson tomorrow it is too late now and if you can opt-out will be fine too maybe I am doing something wrong that I don't see and if the other person can remote my computer will be much better, thank you very much for all your help and have a good night
Expert:  Jennifer French replied 1 year ago.

You too.

Expert:  Jennifer French replied 1 year ago.

If you were able to get a satisfactory answer to your question, please remember to rate the answer so that the expert can receive credit, as this is their livelihood. Thank you for using Just Answers and have a great day!

Customer: replied 1 year ago.
I am not sure if I will be able to connect to Jennifer French, but I will like to ask her if she will be able to help me with another question that so far none had respond.
I created a POS system in Access, I have a pole display LDX9000/PDX3000 and I need some code to sent characters to my pole displays I have no idea from where to start. Do you think you could help me? I will be back to my computer around 10pm tonight
Expert:  Jennifer French replied 1 year ago.

I appreciate the thought! I am actually headed out of town at the moment and was checking my messages really quick.

We have many talented Experts here who will be glad to assist you. I will be back on Monday if you'd like to speak with me. I will opt out but if you want to wait, just let us know and I'll help you on Monday.

Jennie

Customer: replied 1 year ago.
I really appreciated you responded to my message. An expert was supposed to respond a hour ago but it has not happened yet.
I keep waiting and if I don't get an answer by Monday will send you a message. Enjoy the weekend.
Customer: replied 1 year ago.
Hello Jennifer I wonder if you can help me with this new question. An expert email me yesterday but he only asked my for the type of pole display I have and never answer me again. Do you think you can help again?
I created a POS system in Access, I have a pole display LDX9000/PDX3000 and I need some code to sent characters to my pole displays I have no idea from where to start. The pole is connected USB, when I ran the test for the first time it showed the word "TEST" but now is showing some weird characters
Customer: replied 1 year ago.
Hi Jennifer I wonder if you can help me with this the pole display issue. Other experts have emailed me but one didn't finish his communication and the other two were pasting and copying instructions from the internet that I have already tried without any success. You seem to know a lot about access and I appreciated your patience with me when you helped me out with the cash register. Do you think you would be able to help me resolve my issue? If not, I will keep trying other experts. Please let me know.Thank you,
Niurka A.