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

integrating listboxes selected items into ADO filter

Status
Not open for further replies.

WD500

Technical User
Oct 1, 2007
1
DE
Hi all,
i found difficlties to build the right code to build criteria to an ADO filter based on several selecteditems from list boxes.
does anyone have an idea how it can be done?
 
I can think of two ways.

the first is to loop the selected items and dynamically build a where clause, with each item representing a value. For example you would end up with

WHERE (field = '1' OR field = '2' or field = '3')

etc.

Second item is to have a table at the backend, and for each selected item, insert a value into this table along with the ID of the current user.
You then join to this table on the field with the values in equalling the values in another table, and also on the login ID being the login ID of the current user - which gives you multi user capability.

You have to be careful to erase the current users selections though whenever they run the screen.
An alternative of user ID is to use the spid of the connection, but you then have to be careful of the reuse of different spids by different connections.


John
 




For multi-select, I'd build a function to return a LIST of the selected values like 'val1','val2','val3' then use the list in an IN statement...
Code:
sSQL = sSQL & "Where [FldName] IN (" & NewListFunction(lstBox) & ")"


Skip,

[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top