By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,510 Members | 1,451 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,510 IT Pros & Developers. It's quick & easy.

Null List box

P: n/a
I am trying to make code branch depending on whethter there are any entries
in a list box on the form. No matter what I do, the code decides there are
no entries, even when there are.

I created this simple code to illustrate it.

If IsNull(lstBoxTest) Then

GoTo NoEntries

Else

MsgBox "you have some entries in your list box"

Exit Sub

NoEntries:

MsgBox "you have no entries in your list box"

End If

This shows me the "NoEntries" message no matter if there are entries in the
list box or not.

The list box is an Extended Multi Select type.

What am I doing wrong or what bad assumption have I made?

dixie


Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> If IsNull(lstBoxTest) Then

This will tell you that there has not been a selection made in a non
multiselect listbox. It doesn't tell you whether or not there are any items
in the list. To find that try

If lstBoxText.ListCount = 0 Then

If you set the ColumnHeads property of the listbox to Yes, then that counts
as one row and you may need to change the above to =1.

--
Wayne Morgan
MS Access MVP
"dixie" <di****@dogmail.com> wrote in message
news:38*****************@nnrp1.ozemail.com.au...
I am trying to make code branch depending on whethter there are any entries in a list box on the form. No matter what I do, the code decides there are no entries, even when there are.

I created this simple code to illustrate it.

If IsNull(lstBoxTest) Then

GoTo NoEntries

Else

MsgBox "you have some entries in your list box"

Exit Sub

NoEntries:

MsgBox "you have no entries in your list box"

End If

This shows me the "NoEntries" message no matter if there are entries in the list box or not.

The list box is an Extended Multi Select type.

What am I doing wrong or what bad assumption have I made?

dixie

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.