View Full Version : Mulit-Select from List box


will
10-10-2001, 12:37 PM
I have a list box set so I can highlight multiple entries in the list box. Is there a way that I can send the highlighted entries to a report and display all the relevent data associated with each entry?
(I want to pass the ID's from the list box to the report so I can display other information from the ID on other tables in the report as well)
Thanks

R. Hicks
10-10-2001, 04:12 PM
Here is an example of a SubRoutine that does what you ask:

Private Sub cmdPrintReport_Click()
Dim varItem As Variant
Dim strWhere As String

For Each varItem In Me![YourListBoxName].ItemsSelected
strWhere = strWhere & "YourIDField=" & Me![YourListBoxName].Column(0, varItem) & " Or "
Next varItem

strWhere = Left(strWhere, Len(strWhere) - 4) 'Remove the last " Or "

DoCmd.OpenReport "YourReportName", , , strWhere

End Sub

Change all the names of the controls in the code above to the actual names of your controls.

HTH
RDH

Jack Cowley
10-10-2001, 04:22 PM
Ya beat my by seconds Ricky....

[This message has been edited by Jack Cowley (edited 10-10-2001).]

R. Hicks
10-10-2001, 04:36 PM
Only because I am a couple of years younger than you Jack ..... LOL

RDH