Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox Question.....

Status
Not open for further replies.

Jelloshot1

Technical User
Aug 5, 2001
20
0
0
US
Hello All,
This should be an easy one. At least that's what I thought.
Here goes....
I want to generate a report based on the items selected in a ListBox. The ListBox contains Names. The report should put the names in order of Seniority.
In the query that the report is based on I have the following criteria in the Name field:
forms!frmMyForm!List1
As long as the MultiSelect property in the ListBox is "None", the report generates correctly. Of course I'm limited to selecting only 1 item. When I change the Multiselect to Simple, the report comes back with no data.
Like I said, I know this should be easier that what it is. For now I'm using a Text box to type the names in, separeted with a coma and using the InParam Function. This actuall works well but being able to "select" a name would be much easier that "typing" name.
Hope someone out there can provide a little guidence....
Happy Holidays!
Mary (JelloShot1)
 
Here's a routine I use. It lets you select multiple records from a listbox and then opens a form showing only those records. You'll have to do a little tweaking for your particular needs but it should point you in the right direction

Private Sub cmdViewPickup_Click()

Dim strsql As String, crit As String
Dim ctl As Control, frm As Form, itm As Variant

Set ctl = Me!lstPickup

For Each itm In ctl.ItemsSelected
crit = crit & " or "
crit = crit & "[IdPickup]=" & ctl.ItemData(itm)
Next itm

If Mid$(crit, 5) = "" Then
Exit Sub
Else
strsql = Mid$(crit, 5)
DoCmd.OpenForm "frmPickupEntry", , , strsql
End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top