Solved How to Print ListBox Selected Multiple Data Record (1 Viewer)

smtazulislam

Member
Local time
Today, 22:56
Joined
Mar 27, 2020
Messages
521
I have a search List box where have a Search button.
After the results display some data. I want to print out from listbox choice multiple records.
How can I do that ?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:56
Joined
May 7, 2009
Messages
14,021
dim var as variant
for each var in Me.lstBox.ItemsSelected
docmd.OpenReport REportName,View:=acViewPreview,WhereCondition:="ID = " & Me.lstBox.Column(0, var)
next
 

smtazulislam

Member
Local time
Today, 22:56
Joined
Mar 27, 2020
Messages
521
dim var as variant
for each var in Me.lstBox.ItemsSelected
docmd.OpenReport REportName,View:=acViewPreview,WhereCondition:="ID = " & Me.lstBox.Column(0, var)
next
Thank you so much.
Its work, Only one record.
But I would like multiple records.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:56
Joined
May 7, 2009
Messages
14,021
acViewPreview, i think is modal? so it doesn't advance to next record.
 

smtazulislam

Member
Local time
Today, 22:56
Joined
Mar 27, 2020
Messages
521
You talking about Report Modal = Yes/No ;
My setting is Modal = No.
But I tried Modal = Yes
Its not work.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:56
Joined
May 7, 2009
Messages
14,021
using Allen Brownes multi-instance.
the report is in report view.
select some items on the listbox.

see module2.
 

Attachments

  • frmClass.accdb
    992 KB · Views: 90

smtazulislam

Member
Local time
Today, 22:56
Joined
Mar 27, 2020
Messages
521
Multiple selected record, Its opened Multi reports.
Not only one report.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:56
Joined
May 7, 2009
Messages
14,021
ooh, i see.
try this code:

dim var as variant
dim strIDs as string
for each var in Me.lstBox.ItemsSelected
strIDs = strIDs & Me.lstBox.Column(0, var) & ","
next
if len(strIDs) <> 0 then
strIDs = Left$(strIDs, Len(strIDs)-1)
docmd.OpenReport ReportName,View:=acViewPreview,WhereCondition:="ID In (" & strIDs & ")"
end if
 

Users who are viewing this thread

Top Bottom