Where has "LPRINT" done (1 Viewer)

kirkm

Registered User.
Local time
Today, 18:14
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.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:14
Joined
Oct 29, 2018
Messages
21,467
Hi. Before using PrintOut, try selecting the table first. Check out the SelectObject method.
 

kirkm

Registered User.
Local time
Today, 18:14
Joined
Oct 30, 2008
Messages
1,257
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
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:14
Joined
Oct 29, 2018
Messages
21,467
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.
 

kirkm

Registered User.
Local time
Today, 18:14
Joined
Oct 30, 2008
Messages
1,257
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.
 

Cronk

Registered User.
Local time
Today, 16:14
Joined
Jul 4, 2013
Messages
2,772
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
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:14
Joined
Oct 29, 2018
Messages
21,467
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.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:14
Joined
Feb 28, 2001
Messages
27,172
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

Top Bottom