Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing files from Access

Status
Not open for further replies.

Waynest

Programmer
Jun 22, 2000
321
GB
Hello

I've been asked to provide the facility to print barcodes from an access 2000/sql server project. We're using a kyocera laser printer and are ok with the ctrl codes etc as we've used it before with other apps.

At the moment I have a command button/event procedure which produces a flat file containing the required printer string. If I print the flat file using word etc I get the desired barcodes. What would the code be to send the file to the current printer using access, or is a different approach required? TIA.
 
Yes slightly different.
I have created numerous barcode applications using Access
You could create a function that would open or create an ASCII file and send the characters out that way.
Here is one I did for a different printer
-----------------------------------------
' BarcodeLabelHeader
' An Error occurs and sometimes the file is left open
' so close it first
Close #1

' Delete the file before writing it out
If FileExist("X:\Sales\Serialabel.cmd") Then
Kill "X:\Sales\Serialabel.cmd"
End If

Open "X:\Sales\Shelflabel.cmd" For Output As #1
Print #1, "LABELNAME=X:\Sales\Shelf_2.lbl"
Print #1, "PRINTER=" & Chr$(34) & "SATO CL-608 on \\Smallbserver\SATO CL608" & Chr$(34)
'Print #1, "LABELQUANTITY=1" ' not needed because there is only one label for each anyway
Print #1, "DataType=DELIMITED"
Print #1, "DELIMITER=|"
' Here are the FIVE fields needed for the label
Print #1, "Field=STOCKBAR"
Print #1, "Field=STOCKCODE"
Print #1, "Field=DESCRIPT"
Print #1, "Field=LONG_DESC"
Print #1, "Field=VEND"

Print #1, "LABELDATA=THISFILE"

' this part is the data
Dim db As Database, rst As Recordset, SQL As String
Set db = CurrentDb
' SQL string.
SQL = "SELECT STOCK_CODE, DESCRIPTION, LONG_DESC, ALTERNATE_KEY_1 FROM none_IN_MASTER WHERE STOCK_CODE = '" & Me!Text8 & "';"
Set rst = db.OpenRecordset(SQL)

' Write data to file
Print #1, rst.Fields("STOCK_CODE") & "|" & rst.Fields("STOCK_CODE") & "|" & rst.Fields("DESCRIPTION") & "|" & rst.Fields("LONG_DESC") & "|" & "VEND# " & rst.Fields("ALTERNATE_KEY_1")

Close #1
rst.Close
db.Close
DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
Or visit my WEB site
 
Thanks Doug. That's exactly what we've done already, so I'm glad we're on the right lines. My problem is probably pretty basic, I dont know the code to direct the ascii file to the printer once its created. More help please!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top