Where has "LPRINT" done

kirkm

Registered User.
Local time
Today, 22:56
Joined
Oct 30, 2008
Messages
1,257
From a VBA Sub I'm trying to print a hard copy (actually the field names in a table) and the expected LPRINT command doesn't seem to work. I found "DoCmd.Printout" but that says it "isn't available now".
From File-Print I can see Print Setup dialog has the correct printer and it is on line.
 
Hi. Before using PrintOut, try selecting the table first. Check out the SelectObject method.
 
Hello... selectObject would apply to the whole table, yes? Is it possible to have something like

Code:
Set rr = CurrentDb.OpenRecordset("Table1")
For i = 0 To rr.Fields.Count - 1
lprint i, rr.Fields(i).Name
Next
 
Let’s see. I’m sure a few things are possible. However, since LPRINT is not a valid command in VBA, one possibility is to print the information to a file or to a table and then create a report to print it.
 
I did write a file and printed it with Notepad. I remember LPRINT from an old DOS basic and would have thought there was some current equivalent.
 
Lprint is a BASIC command, not VBA.


You could output to the immediate window then copy into Notepad, word or whatever and print from there.


Code:
Set rr = CurrentDb.OpenRecordset("Table1")
For i = 0 To rr.Fields.Count - 1
   debug.print i, rr.Fields(i).Name
Next
 
I did write a file and printed it with Notepad. I remember LPRINT from an old DOS basic and would have thought there was some current equivalent.
Hi. Glad to hear you found a way to make it work. You have a good point about LPRINT; unfortunately, I don’t know what, if any, replaced it.
 
You have a recordset. If you could build a sufficiently selective query based on that recordset, you could perhaps tell Access to send the query to a file and then trigger printing from there. Look up DoCmd.OutputTo for one possible method.

LPRINT doesn't work directly to a printer these days because the correct command is PRINT (to an output channel). The original meaning of LPRINT (print a complete line) is accomplished by NOT ending your PRINT argument list with a semicolon.
 

Users who are viewing this thread

Back
Top Bottom