Empty Combobox rowsource Returning ListCount of 1

accessNator

Registered User.
Local time
Today, 04:31
Joined
Oct 17, 2008
Messages
132
I have a combo box which I define a SQL statement as its rowsource.

When I open the form, I have yet to define the SQL statement for the combo box.

My code is:
Code:
if me.cmbobox.listcount = 0 then
me.cmbobox.enabled = false
else
me.cmbobox.enabled = true
end if
But it shows the box as still enabled.
When I do debug.print me.cmbobox.listcount, it shows a value of 1. But that is impossible since I have yet to define a rowsource for it or its empty.

I also have column heading turned off too.

Thoughts?
 
listcount starts from 1 so try

Code:
if me.cmbobox.listcount-1 = 0 then
    ....
but simpler code would be

Code:
me.cmbobox.enabled = me.cmbobox.listcount>1
 
listcount starts from 1 so try

Code:
if me.cmbobox.listcount-1 = 0 then
    ....
but simpler code would be

Code:
me.cmbobox.enabled = me.cmbobox.listcount>1


Thanks for your reply. Its weird that when the row source is set to nothing, it still wants to think there is a record in place.

I saw an interesting post after doing more searches with another workaround here in another forum who another poster posted the same problem.

http://www.utteraccess.com/forum/A2002-ListCount-bug-t1427385.html&st=20

Look at the post #32 from datAdrenaline on the thread. Interesting.
 
Last edited:
Interesting thread:

you have the ColumnHeads property set to TRUE, the .ListCount will be "off by one" since the Headers are considered a row
I was aware of but didn't think to mention since they usually are set to true - sorry I forgot to say
 

Users who are viewing this thread

Back
Top Bottom