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

select/clear all button for a listbox 1

Status
Not open for further replies.

davyre

Programmer
Oct 3, 2012
197
AU
Hi,
I have a list box, and I create a button to automatically select all the items in that listbox.
here's the code:
Code:
If UnitIDBox.ListCount = 0 Then
    MsgBox ("The list is empty")
    Exit Sub
End If

If IsNull(UnitIDBox.ItemsSelected) Then
    Call SelectAll(Forms!FrmWholeDelivery!UnitIDBox)
    MsgBox ("A")
Else
    Call ClearList(Forms!FrmWholeDelivery!UnitIDBox)
    MsgBox ("B")
End If

the problem is the vba never went to IF clause (always go to ELSE), so there should be a problem. Can anyone help?Is the condition will always false?
 
I don't think a collection can be null.
What about this ?
If UnitIDBox.ItemsSelected.Count = 0 Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top