By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,471 Members | 2,277 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,471 IT Pros & Developers. It's quick & easy.

listbox value to be used for query

P: 20
Dear all,

I have developed one interface where user can select a single value form list box and system will take the selected value for retrieving records form my table.

Now My Question is how a user can select multiple value form list box and system take that for search .I now I have to change list box :multi select property to "simple or extended".but how to get value returned form selection can be taken.

suppose My list box has:
country name:
USA
UK
Austria
canada
etc.......

now a user want to see both usa and uk customer or even some time uk ,usa,and canada.how to retrieve data.

in single search i m using:

If Not IsNull(Lstcountry.Value) And Len(Lstcountry.Value) > 0 And Lstcountry.Value <> "ALL" Then
SWHERE = SWHERE & "[country]='" & Lstcountry.Value & "' And "
Else
SWHERE = SWHERE
End If
Plz can any body help me.!
Thanks.
Jan 12 '07 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Dim valSelect As Variant
  2.  
  3.   SWHERE = SWHERE & "[country] IN ("
  4.   For Each valSelect In lstcountry.ItemsSelected
  5.       SWHERE = SWHERE & "'" & Lstcountry.ItemData(valSelect) & "', "
  6.   Next valSelect
  7.  
  8.   'Remove the last comma
  9.   SWHERE = Left(SWHERE, Len(SWHERE)-2)
  10.   'Add a closing bracket
  11.   SWHERE = SWHERE & ")"
  12.  
Jan 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.