ListBox.ListCount verus actual number of rows??

JDB

Registered User.
Local time
Today, 05:15
Joined
Mar 10, 2013
Messages
13
I am having some problems using a listbox with multi-select, so I was printing out the listcount with a debug.print function.

I notice that the listbox.listcount is always greater by one(1) than the actual number of items (rows) and this has me puzzled.

So if I have 11 items or rows in the list box from a query, the listcount prints out 12, and so forth.

Does anyone know the reason for this.

Thanks

JDB
 
Would it surprise you to find it in the description of the listcount property? Look it up in the help file or on the web.
 
Thanks very much for your sage advice. I have spent a good deal of time already on that help page. it is repeated below:

The question remains;
my query has 11 rows, my listcount is 12
my query has 2 rows, my listcount is 3
and so forth.

JDB


from a microsoft site

"You can use the ListCount property to determine the number of rows in a list box or the list box portion of a combo box. Read/write Long.
expression.ListCount
expression Required. An expression that returns one of the objects in the Applies To list.
Remarks
Microsoft Access sets the ListCount property to the number of rows in the list box or the list box portion of the combo box. The value of the ListCount property is read-only and can't be set by the user.
This property is available only by using a macro or Visual Basic . You can read this property only in Form view and Datasheet view.
The ListCount property setting contains the total number of rows in the combo box list or list box, as determined by the control's RowSource and RowSourceType properties. If the control is based on a table or query (the RowSourceType property is set to Table/Query and the RowSource property is set to a particular table or query), the ListCount property setting contains the number of records in the table or query result set."
 
Do you have the Column Heads property of the list box set to yes.
 
Q- Do you have the Column Heads property of the list box set to yes.

Ans - I surely do and that is surely the reason. I changed the Column Heads property to "No", and now there is a listcount of 11 instead of 12.

Thanks very much

JDB
 
The reason I pointed you to the docs is that 75% of questions posed here are posed by people that use AWF as a crutch, instead of being able to face the rough world by them selves and find what they need in 5 sec in the docs. The information that Bob "helped" you with is in the next paragraphs in the documentation page you apparently did find but did not read.
 
Spike, I read it, but it did not register. Actually, I probably read it 5 times but it did not register.

Thanks for pointing this out.

JDB
 

Users who are viewing this thread

Back
Top Bottom