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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listbox multiselect

Status
Not open for further replies.

stevedi

Programmer
Aug 23, 2002
23
US
Hi,

I have a listbox on a form that I use to filter records using a select query. I use [Forms]![theForm]![ListName] as criteria in the select query. The query runs if the listbox multiselect property is set to none. I would like to be able to make multiple selections in the listbox this having multiple OR criteria in the select query. However when I set the multiselect property to Simple or Extended the query runs but no records are returned.

Any thoughts as to what's going on would be appreciated.

Thanks
SteveD
 
I would buiid my WHERE Clause programatically.
Like this.....put in some function...then use the SQL string

Dim Select_ls a string
Dim From_ls as string
Dim Where as string
Dim SQL_ls a string

Dim j as long
j = 0

Select_ls = “SELECT *” & vbcr
From_ls = “FROM Table_Name” & vbcr


For j = 0 To List.ListCount - 1
If List.Selected(j) = True Then
Where=Where & "FIELD_NAME='" & List.ItemData(j)& "' OR "
End If
Next j

If LenB(Where) > 0 Then
Where = Left(Where,Len(Where)-3)
Where = “WHERE “ & Where
Endif

SQL_ls = Select_ls & From_ls & Where
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top