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

List Box - Determining which selection clicked 1

Status
Not open for further replies.

Maquis

Programmer
Jul 19, 2001
934
US
In a multi-select listbox is there a simple way of determining which item was just clicked.

Here's the situation. I have a listbox on my form with about 10 items in it. The users have asked that if a certain item is selected then no other selections in the box are allowed and vice versa. However if any other item is selected then multiple selections are allowed.

For example if item #3 is the exclusive one then if a user selects #3 then all other selections should be cleared, but if the user clicks something other than #3 then #3 should be cleared and the other selected items remain.

Did that make sense? Any ideas, I'm stumped.

Maq [americanflag]
<insert witty signature here>
 
If you need help with the code, let me know.

I hope this solution works...
So in the table/query that drives your listbox, you add a field. This field is to contain values to determine if the user can select this and other items or only this item. You tell this value to be Yes/No (Boolean). If 0 then the user can select this item as well as others, if -1, then only this item. You can check with the OnClick event what item(s) are currently selected then read the value of the column, which i should add has a set width of 0.

so kinda: if selected item column9 = -1 then msgbox(&quot;only this item can be selected&quot;) else check next selected item for its column9 value

i hope this gets you started
 
Oh ok, I didn't think of approaching the problem from that angle. I was trying to clear the selections automatically rather than locking them out. Basically, with your method the user would not be able to even click the exclusive item if something else is clicked. They would have to deselect the other items first. Also vice versa, I could set the box to single select only if the exclusive item gets clicked.

That will work perfectly! Thanks a bunch for kickstarting my brain into a new direction.

Maq [americanflag]
<insert witty signature here>
 
Oh, well in that case, let me give you the names and addresses of the users that requested this mod. [thumbsup2]

Maq [americanflag]
<insert witty signature here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top