Pardon me.
ListCount counts the number of items in the list. It doesn't tell you how
many (if any) have been selected.
ItemsSelected.Count will give you a count of the items that have been
selected with a multi-select listbox.
So, I believe you would have to use
Me.MyCommandButton.Enabled = Me.MyListBox.ItemsSelected.Count <> 0
"Klatuu" <(E-Mail Removed)> wrote in message
news:8EB2D4E6-AD95-4E53-B376-(E-Mail Removed)...
>I don't think that will work like you expect it to. I would suggest using
> the ListCount property of the List box.
>
> Private Sub ListBox_AfterUpdate()
> Me.MyCommandButton.Enabled = Me.MyListBox.ListCount <> 0
> End Sub
>
> If No selections have been made, the ListCount will be 0 which will return
> False; otherwise, it will return True.
>
>
> "Martin" wrote:
>
>> In design view, make sure the cmdButton is disabled (and remember to save
>> the
>> form with it still disabled - easy to forget after fiddling with the
>> macros!).
>>
>> Go to properties of the list box and use the builder button next to After
>> Update event. This event is triggered every time a selection/deselection
>> in
>> the list made. The kind of code you could use is:
>>
>> Private Sub ListBox_AfterUpdate()
>> If IsNull(ListBox) Then
>> cmdButton.Enabled = False
>> Else
>> cmdButton.Enabled = True
>> End If
>> End Sub
>>
>>
>> "Dheinze57" wrote:
>>
>> > I use a cmdButton to print reports filtered by a list box with multi
>> > select
>> > set to "simple" (http://allenbrowne.com/ser-50.html).
>> > How can I disable the cmdButton when there are no selections. (If there
>> > are
>> > no selections it runs the report with the last filter saved with the
>> > report)
>> >