Combo box list count (1 Viewer)

Sun_Force

Active member
Local time
Tomorrow, 02:26
Joined
Aug 29, 2020
Messages
396
I have a combox and a textbox next to each other.
The text box is used to show the count of the items in the combo box.

The text box control source is : =[Name_of_combobox].[ListCount]

But the text box always shows one more than the real count. It means that if the combo box has 10 items, the textbox shows 11.
If it combo has 6 items, textbox shows 7.

Even if ListCount is a 0 base property it should show one less. Not more.

Any advice?

Thank you.

2021-05-20_9-27-01.jpg
 
Last edited:

LanaR

Member
Local time
Tomorrow, 03:26
Joined
May 20, 2021
Messages
113
From your screenshot, it would appear that you have the Combo's "Column Heads" set to "Yes". The [ListCount] function will count the header as an item in the list so simply set your code to =[Name_of_combobox].[ListCount]-1
 

GinaWhipp

AWF VIP
Local time
Today, 13:26
Joined
Jun 21, 2011
Messages
5,900
The Column Header is included in your count. You will need to add a *-1* to exclude it.
 

Sun_Force

Active member
Local time
Tomorrow, 02:26
Joined
Aug 29, 2020
Messages
396
I should have guessed that.
But still I fail to understand why Microsoft counts the header in the ListCount.
It's like you use a DCount of a set of data in a table, and you receive one more than the real count because of table's header.
 

Gigitty

Member
Local time
Today, 10:26
Joined
Mar 29, 2007
Messages
52
I came across this issue many years ago and yes, was frustrated by the fact that the column header is counted, so had to use the -1 process.
 

Users who are viewing this thread

Top Bottom