Public Function basPrnBarCode()
'From Tek-Tips; DougP 1/12/01
' BarcodeLabelHeader
' An Error occurs and sometimes the file is left open
' so close it first
'Actually, I would not do it this way, but use the MLR
'FreeFile to get an open Handle MLR
'But then you need to change the '#1' to whatever
'you call the FreeFile
Close #1
'This isn't necessary. Opening the file for output does it MLR
' Delete the file before writing it out
If FileExist("X:\Sales\Serialabel.cmd") Then
Kill "X:\Sales\Serialabel.cmd"
End If
'Of Course, you need to replae the Filename )"X:\ ... " MLR
'the fully qualified path name of your choice MLR
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
End Function