Sending data to a serial or parallel port from Access

K

ksteger

I have a custom billing application that I support for a small utility
company that we wrote using MS Access. They want to add the electronic
cashiering capabilities complete with the barcode scanning, receipt
printer and cash drawers that pop open when a transaction takes place.

Now I know how to do the bar code scanning part. I understand
logistically how to communicate with the printer (which in turn
communicates with the cash drawer). What I don't know is how to do that
from MS Access. For that matter I am not even sure if it is possible to
do from Access.

The printer documentation has all the hexidecimal codes to do
everything I need to do with the printer including to tell it to open
the cash drawer. What I don't have a clue how to do is send that data
from Access to the serial or parallel port.

Now of course I can always go the course of finding a company with the
software for cashiering services but at this point I would rather not
do that if possible.

I wasn't sure which topic to put this under to begin with so I just
went for the general topic. Any insight anyone can give me is greatly
appreciated.

Thanks!
-Kim
 
R

Ron Hinds

I have a custom billing application that I support for a small utility
company that we wrote using MS Access. They want to add the electronic
cashiering capabilities complete with the barcode scanning, receipt
printer and cash drawers that pop open when a transaction takes place.

Now I know how to do the bar code scanning part. I understand
logistically how to communicate with the printer (which in turn
communicates with the cash drawer). What I don't know is how to do that
from MS Access. For that matter I am not even sure if it is possible to
do from Access.

The printer documentation has all the hexidecimal codes to do
everything I need to do with the printer including to tell it to open
the cash drawer. What I don't have a clue how to do is send that data
from Access to the serial or parallel port.

Now of course I can always go the course of finding a company with the
software for cashiering services but at this point I would rather not
do that if possible.

I wasn't sure which topic to put this under to begin with so I just
went for the general topic. Any insight anyone can give me is greatly
appreciated.

Thanks!
-Kim

You can Open a LPT port for writing just like opening a file for writing.
Then, write the hex codes to it. I don't remember the exact syntax but it
should be fairly easy to find in the Help files. Something like:

Dim iFile As Integer
Dim HexCodes As String

iFile = FreeFile
Open "LPT1" For Output As iFile
'send hex codes etc.
Print iFile, HexCodes
Close iFile
 
K

ksteger

I have tried what you stated with a sample Hex string that I know
works. I am getting the following error:
438: Object doesn't support this property or method

I get this on the line that says:
Print iFile, HexCodes

I have searched the help files and they have been no help. Now past
experience would leave me to lean towards possibly missing a reference
file. However, there are an ton of reference files and I am not sure
which one I could be missing.

Any ideas are greatly appreciated.

Thanks,
-Kim
 
R

Ron Hinds

I think the problem may be in the Open statement. You may need a colon after
LPT1. I also left out a couple of options that may be important. Try this
Open statement instead:

Open "LPT1:" For Binary Access Write Shared As iFile

You may need to experiment some. I have successfully used this method in the
past but unfortunately it is "two-day old code" so I don't recall all of the
details ;-)
 
U

UpRider

Here is a the complete module that I use to print labels to a dot matrix
printer on LPT1: It works fine.
Perhaps you can adapt it to your use. The chr() defines bytes (hex or
ascii). e.g. Chr(27) is the ESC character.

UpRider

Option Compare Database
Option Explicit
'PRINT TO LPT PORT TO EPSON 500
'---------------------------------------------------------------------------------------
' Procedure : subPrintDotMatrixLabels
' DateTime : 7/16/2002 10:19
' Author : David
' Purpose : Access reports eject a page at eoj, which wastes tractor feed
labels.
' : This sub prints directly to lpt1 a line at a time.
' : myquery is the data source for the labels, arg controls type
of label to print;
' : 0 or null - print regular label
' : 1 - print sticker label to ask for new email address
'---------------------------------------------------------------------------------------
'
Sub subPrintDotMatrixLabels(myquery As String, Optional arg As Integer)
Dim intBlankline As Integer
Dim X As Integer
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Set db = CurrentDb()
Set qdf = db.QueryDefs(myquery)
Set rst = qdf.OpenRecordset()
Open "LPT1" For Output As #1
'Initialize printer, Epson 500
Print #1, Chr(27) + Chr(120) + "1" + Chr(27) + Chr(67) + "6" + Chr(27) +
Chr(77)
' Print #1, Chr(27) + Chr(77)
Select Case arg
Case 0
Do While Not rst.EOF
intBlankline = 3
Print #1, LTrim(rst![FIRST] & " " & rst![LAST])
Print #1, rst![ADDR1]
If Len(rst![ADDR2]) > 0 Then
Print #1, rst![ADDR2]
intBlankline = intBlankline - 1
End If
Print #1, rst![CITY] & " " & rst![ST] & " " & rst![ZIP]
For X = 1 To intBlankline
Print #1, " "
Next
rst.MoveNext
Loop
'advance 5 lines (1 label)
intBlankline = 5
For X = 1 To intBlankline
Print #1, " "
Next X
Close #1
Case 1
Do While Not rst.EOF
Print #1, LTrim(rst![FIRST] & " " & rst![LAST])
Print #1, rst![ME_MAIL]
Print #1, "Your Emailed Newsletter bounced. Please"
Print #1, "update your email addr at www.dbtc.org"
Print #1, " "
Print #1, " "
'print #1, " "
rst.MoveNext
Loop
'advance 5 lines (1 label)
intBlankline = 5
For X = 1 To intBlankline
Print #1, " "
Next X
Close #1
End Select
rst.Close
Set rst = Nothing
Set qdf = Nothing
Set db = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top