Print ListBox contents directly?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I thought DoCmd.OpenReport set to acViewNormal would send the contents of my
listbox directly to the printer without opening a report, but OpenReport
wants the name of a report. I can't see how to do it. All I want to do
print a quick & dirty list, no fancy formatting necessary. Am I mistaken on
this?

Thanks!
 
I'm not sure if that what you looking for, but if you just want to print the
form, then try

DoCmd.PrintOut
 
That seems to print out a copy of the form as it appears onscreen. I need
the contents of the listbox on the form.
 
I thought DoCmd.OpenReport set to acViewNormal would send the contents of my
listbox directly to the printer without opening a report, but OpenReport
wants the name of a report. I can't see how to do it. All I want to do
print a quick & dirty list, no fancy formatting necessary. Am I mistaken on
this?

Well, a listbox doesn't "contain" any data. It's a tool for displaying
and editing data.

I'd either create a quick & dirty report based on the listbox's
RowSource query, or simply print the query datasheet.

John W. Vinson[MVP]
 
Try something like this
1. Create a query, call it PrintQuery (for the test), doesnt need to contain
anything
2. Try the code

' Assign the SQL from the list box to the query
Application.CurrentDb.QueryDefs("PrintQuery").SQL = Me.ListBoxName.RowSource
DoCmd.OpenQuery "PrintQuery"
DoCmd.PrintOut
DoCmd.Close acQuery, "PrintQuery"
 
Back
Top