473,383 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Null List box

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
1 1515
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: William Wisnieski | last post by:
Hello Everyone, I have a query by form with several list boxes. The user selects items from the list boxes and clicks a button that returns results in a datasheet subform. One of the list...
7
by: Douglas Buchanan | last post by:
I cannot access certain column values of a list box using code. I have a list box 'lstPrv' populated by the query below. SELECT tblPrv.fkPrvID, lkpCat.CatNm, lkpSrv.SrvNm, lkpCat.pkCatID,...
3
by: oraustin | last post by:
I have a list box whose value I explicitly set to null in code. Then when I include the list box in a query criteria it fails to match but if I replace the criteria with 'null' then it matches...
8
by: frizzle | last post by:
Hi group. I have tho following code. $_GET looks like this: /2006/03/lorem_ipsum $locationinfo = explode('/', trim( $_GET , '/') ); list( $article_year, $article_month, $article_url ) =...
3
by: Amit Bhatia | last post by:
User-Agent: OSXnews 2.081 Xref: number1.nntp.dca.giganews.com comp.lang.c++:818044 Hi, I am wondering if I can assign a list iterator = NULL. Suppose I have a class A: A.h class A{ //ctors...
1
by: connor7777 | last post by:
Hi guys: We've been weeding out errors off of a java->c# project and have managed to redeem most of our code with the exception of one bug that we for some reason cannot pin down. The following...
8
by: A. Anderson | last post by:
Howdy everyone, I'm experiencing a problem with a program that I'm developing. Take a look at this stack report from GDB - #0 0xb7d782a3 in strlen () from /lib/tls/i686/cmov/libc.so.6 #1 ...
3
ADezii
by: ADezii | last post by:
Null as it relates to database development is one of life's little mysteries and a topic of total confusion for novices who venture out into the database world. A Null Value is not zero (0), a zero...
6
by: djm | last post by:
hi, lets say ive this struct array in my header file public: IndepHTable(); private: struct { string word; List defList;
4
by: Deckarep | last post by:
Hey everyone, Is there a more elegant or cleaner way of accomplishing the following null check? List<stringmyString = null; //Purposely null list of strings to show the example XElement...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.