Listbox question

  • Thread starter Thread starter Damon Heron
  • Start date Start date
D

Damon Heron

I have a multiselect listbox that when user clicks on an item, it is
highlighted (selected). some of the items are not appropriate for the task
as hand, but I don't want to remove them from the list. So, when the user
clicks on of the inappropriate item, a msgbox shows that this is not a good
item. User clicks okay, then the focus goes back to the highlighted listbox
item. Here is where I am having a problem. I want to automatically
"un-highlight" the item, because if the user clicks on it again, (to
de-select it) the msgbox returns. This is one extra step I want to get rid
of, but can't figure out how. Thanks in advance.
 
Friend,

joel-ange sitbon has invited you to join GreenZap and get $50 WebCash to
spend online. Sign up for a FREE GreenZap account and get $50 to spend at
hundreds of the world's premier merchants, many of whom are offering
incredible upfront discounts. Click on the link below to go to GreenZap and
signup! All thanks to joel-ange sitbon.

It's Zappening in the GreenZap Storez.
http://www.greenzap.com/joel1962

If you do not want to receive these emails in the future click the link
below:
http://www.greenzap.com/optout_invite.asp
 
I have a multiselect listbox that when user clicks on an item, it is
highlighted (selected). some of the items are not appropriate for the task
as hand, but I don't want to remove them from the list. So, when the user
clicks on of the inappropriate item, a msgbox shows that this is not a good
item. User clicks okay, then the focus goes back to the highlighted listbox
item. Here is where I am having a problem. I want to automatically
"un-highlight" the item, because if the user clicks on it again, (to
de-select it) the msgbox returns. This is one extra step I want to get rid
of, but can't figure out how. Thanks in advance.

Extended or Simple multi-select?
This will cover both. Simple can be done a bit differently.
Let's say the strings "B" or "C" are not permitted to be included in
the selection.
(Watch line wrap)

Private Sub ListBoxName_Click()
Dim VarItem As Variant
For Each VarItem In Me! ListBoxName.ItemsSelected
If ListBoxName.ItemData(VarItem) = "B" or
ListBoxName.ItemData(VarItem) = "C" Then
MsgBox ListBoxName.ItemData(VarItem) & " is not allowed."
ListBoxName.Selected(VarItem) = False
End If
Next VarItem

End Sub
 
The listindex property will have the value of the last selection made:

forms!frmbporeports!lstbillprodoffering.selected(forms!frmbporeports!lstbillprodoffering.listindex) = false
 
The listindex property will have the value of the last selection made:

forms!frmbporeports!lstbillprodoffering.selected(forms!frmbporeports!lstbillprodoffering.listindex) = false

Using ListIndex will work fine for Simple Multi-selection, but it will
not catch a value in the middle of an Extended selection (select the
first value, hold down the Shift key, select the last value).
 
What is determining 'inappropriate item' when it is selected? Are some
combinations not compatible? Or does something else set it up like picking
fruit in another listbox. If this is the case why not use a query with
criteria as record source for the multiselect listbox?
 
The OP wanted to know how to deterime the last (most recent) selection. My
response does exactly that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top