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

List object

Status
Not open for further replies.

BRADLEY21

Programmer
Sep 19, 2002
35
US
Here is an easy one that I can't figure out.

I am using a listbox object and have the multiselect set to true.
Now I want to use the multiple selection in a query. For example:

Select * from mytable where mfield in ('a,b,c,d')

Proble: how do I access the array or variable that contains the multiple selection. If it is an array I can convert it to the variable but am unable to find the ARRAY! It is killing me.

Thanks for any help

 
The help file entry for the listbox has some sampler code to list the "selected" items:
Code:
   ? "Selected items:"
   ? "---------------"
   FOR nCnt = 1 TO ThisForm.lstListBox1.ListCount
      IF ThisForm.lstListBox1.Selected(nCnt)  && Is item selected?
         ? SPACE(5) + ThisForm.lstListBox1.List(nCnt) && Show item
      ENDIF
   ENDFOR
As you can see, you could build a string of the values selected, and then use a macro (up to 26!) in your SQL Select IN list.

Rick
 
I tried the following but it does not work

Select * from mytable where mfield24 in (mvar)

mvar='abc,def,efg'

it only sees abc.
 
Bradley21

I'm not sure that your list ends up in the right format by using a variable, the format shoulg be :

Select * from mytable where mfield24 IN('abc','def','efg')

When your store it in a variable you end up with : 'abc,def,efg', which ends up being one value.




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Bradley,
Actually the string needs to be:
Code:
mvar = '"abc","def","efg"'
Then you need macro substitution - this should work:
Code:
Select * from mytable where mfield24 in (&mvar)
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top