multi list box filter

G

Guest

I appreciate your help in advance. I am new to most of this and I need a
little assistance. I have searched the web and found some articles etc... I
am just not sure how to apply it to mine because I am unfamiliar with some of
the coding etc.. I understand a very little of what people are saying but I
can't quite put it all together.

I have a form called "reportfilterfrm" in this form I have 3 list box's. On
2 of the list box's multi select is selected to "None" and I have them bound
to the criteria field in my query and that works perfect. The 3rd list box
multi select is set to "Simple" and I am not sure how to get the query to
refrence this.

The query is called "reportfilterqry"

listbox #3 is called [opponent] I would like it to be the criteria for
[opponent] in the "reportfilterqry" It is a text field.

Thanks again for your help. I really appreciate it!
 
A

Arvin Meyer [MVP]

You need to put the results of your selections into a textbox (in this code
that would be txtSelected) and use that in SQL code with an IN clause:

Private Sub lstElevation_Click()

Dim varItem As Variant
Dim strList As String
Dim strSQL As String

With Me!lstElevation
If .MultiSelect = 0 Then
Me!txtSelected = .Value
Else
For Each varItem In .ItemsSelected
strList = strList & .Column(0, varItem) & ","
Next varItem
If strList <> "" Then
strList = Left$(strList, Len(strList) - 1)
End If
Me.txtSelected = strList
End If

End With

strSQL = "Select * From MyTable WHERE ID In (" & Me.txtSelected & ")"

End Sub
 
G

Guest

Thanks for all your help. How do I get the results of my selection into the
textbox?
 
A

Arvin Meyer [MVP]

Fipp said:
Thanks for all your help. How do I get the results of my selection into
the
textbox?

This line of code in the snippet does it:

Me.txtSelected = strList
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top