how to tell if an item selected in listbox

  • Thread starter Thread starter JEM
  • Start date Start date
J

JEM

Another question today....In an unbound form, how can I find out if
anything was selected in a listbox? I want to be able to only fire
some code if something was selected. I don't need to know which item
was selected at this point, just whether or not something was.
 
use the built in len function

IF len(me.cboCombo) > 0 then
     do something
Else
     do something else
End IF

Thanks, but I don't think that will work with a listbox.
 
If Not IsNull(Me!Listbox) Then
MsgBox "Something was selected"
End If

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
If Not IsNull(Me!Listbox) Then
    MsgBox "Something was selected"
End If

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia






- Show quoted text -


Thanks, i wish it was that simple, but it doesn't work. Even with
items selected it still sees it as Null. I also tried:

If not isnull(me.listbox.ItemsSelected) then
'do something
end if

Other ideas?
 
Thanks, i wish it was that simple, but it doesn't work. Even with
items selected it still sees it as Null. I also tried:

     If not isnull(me.listbox.ItemsSelected) then
              'do something
     end if

Other ideas?- Hide quoted text -

- Show quoted text -


Duh! Here it is:

If me.listbox.ItemsSelected.Count > 0 then
'do something
End if
 
...i wish it was that simple...
It is that simple, but I assumed you had MultiSelect = No. My mistake!

By the way, ItemsSelected.Count won't work when MultiSelect = No and testing
occurs in the listbox's Click event.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia


If Not IsNull(Me!Listbox) Then
MsgBox "Something was selected"
End If

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia






- Show quoted text -


Thanks, i wish it was that simple, but it doesn't work. Even with
items selected it still sees it as Null. I also tried:

If not isnull(me.listbox.ItemsSelected) then
'do something
end if

Other ideas?
 
Back
Top