Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filtering records by list box.
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00787216
Message ID:
00787313
Views:
20
I would put a button by your listbox that says "DoQuery"
In its click(), I would iterate through your list and make a delimited filter string:
Public G_FilterStr   && Persistent scope.  This isn't tidy OOP but it works 
G_FilterStr="|"
with thisform.list1
For i=1 to .listcount
  if .selected(i)
    G_FilterStr=G_FilterStr + .list(i) + "|" 
  endif
endfor
endwith 
set filt to atc(trim(department),G_FilterStr) > 0
Browse Nowait Normal   
that's all you need.

if the values of T1...TLast can potentially be subvalues of each other (for example, "USELESS","VERYUSELESS", then the field would need have delimiters applied to guarantee correct results:
set filt to atc("|"+trim(department)+"|",G_FilterStr) > 0




>Hi
>
>I have a form with a list box which has several values i.e. T1, T2, T3 ..........T7. This list box is not connected to any table. The values are added manually. I have a table from a database application which has thousands of records. One of those fields is called department and contained within the field are the values T1 or T2 or T7 etc.
>
>What I would like to do is to use the list box on my form (multiple select) and then click a button to find those records that match what I have selected in the list box. For example if I select T2 and T7 then it would list those records that have T2 and T7 in the department field. I suppose I need some looping statement to do this. Can anybody start me down the right path.
>
>Thankyou very much!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform