SueB wrote:
[color=blue]
> Hey, Salad...
>
> Is there a way to "unselect" items in a listbox, programmatically?
> Here's what I want to (and I've been trying to to this while debugging
> the form, but I've been unsuccessful) ...[/color]
Sure
Let's say you have a multiselect listbox. And you want all items
selected to be set to unselected. In some event you could have code
that looks like this
Dim varItem As Variant
For Each varItem In Me.ListBoxName.ItemsSelected
Me.ClientList.Selected(varItem) = False
Next varItem
[color=blue]
>
> I have the option buttons in an options group: 1 button for the first
> listbox and 1 button for the otgher listbox.
>
> Let's say the user selects optionbutton 1 and enables the first listbox.
> Then they select a few items in the first listbox.
>
> Then they decide (before hitting the command button to generate the
> query) that they really want to use the 2nd list box. So, they hit the
> other option button, which will disable listbox 1 and enable listbox 2.
> However, the items that were selected in listbox 1 are still
> highlighted. I want to get those highlighted items unhighlighted
> (unselected).[/color]
I would clear out the selections for both listboxes when you go to a new
record. Or else have a command button to clear out the selected
entries. I would not clear it out by selecting which listbox to use
(see clear out code above)
I can see your dilemma but I'd not do that. I try, as much as possible,
to have sympathy and empathy for the poor user. If I can do as much as
possible to fill in values or make their keystrokes less then I feel I
succeed.
So if a user selects ListBox2, and has selected the items from ListBox1,
and now decides ListBox1 is the right one, if you've cleared it out then
the person needs to reselect all of the items.
Let's say you have 2 listboxes; Listbox1/2. Lets say you have an option
group (Frame1) with 2 checkboxes, you could do something like this
Me.ListBox1.Enabled = (Me.Frame1 = 1)
Me.ListBox2.Enabled = (Me.Frame1 = 2)
based upon the selection.
Now, you have a command button to press when the selections are pressed.
And your code does something like
Dim strSQL As String
If Me.Frame1 = 1 then
strSQL = ...
Else
strSQL = ....
endif
...process something
[color=blue]
> Any ideas?
>
> Regards,
> SueB
>
> *** Sent via Developersdex
http://www.developersdex.com ***[/color]