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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer object in Access 1

Status
Not open for further replies.

jonnyk

Programmer
Jan 11, 2001
19
0
0
GB
I have written a routine in VB to write a text file to the printer using the printers collection and printer object. I transferred this code to an access application and could not find any reference to the printer object or collection.
Is this the right way to print a flat file from within access or do I need a different approach
 
Different approach, at least fo Ms. Access '97. Ms. Access '97 does not include the printer object, but only the printers collection (provides only the selection of printer drivers, (A.K.A. Printers).

In the general/junk sense, Ms. Access would just use a print or write satement. Of course this provides little or no formatting control (font selection/size, etc). This is really not much different than just using notepad, but you can at least parse the input to re-set the line breaks, or line up columnar info.

You could copy the text file to an array or temp recordset and base a report on that array or record set. Then just print the report. This would let you do everthing you want re formatting, but it is a bit more work.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
In detail, the file I am trying to print is a text file containing control characters that will instruct the printer to print barcodes. What is the command to use ?
 
DougP is the BarCode Guru, and he happened to post this earlier today. Give him FULL credit for the code, I am just passing it along.

Code:
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

Again, The credit for this goes to DougP



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top