ListCount

D

DS

I have this on the OnClick propert of the ListBox. It should return 0
if the list is empty bu it always returns a 6.
Any help appreciated.
Thanks
DS

If Me.ListSubMods.ListCount = 0 Then
Me.TxtAction = 0
ElseIf Me.ListSubMods.ListCount >= 1 Then
Me.TxtAction = 6
End If
 
W

Wayne Morgan

Is there any chance that you're leaving "blank" records in the listbox so
that there are 6 rows, but nothing visible? If you click into the listbox,
can you select a row?
 
R

Rick Brandt

DS said:
I have this on the OnClick propert of the ListBox. It should return 0
if the list is empty bu it always returns a 6.
Any help appreciated.
Thanks
DS

If Me.ListSubMods.ListCount = 0 Then
Me.TxtAction = 0
ElseIf Me.ListSubMods.ListCount >= 1 Then
Me.TxtAction = 6
End If

Do you have ColumnHeadings displayed in the ListBox? That will cause the
ListCount to always be at least 1.
 
D

DS

Wayne said:
Is there any chance that you're leaving "blank" records in the listbox so
that there are 6 rows, but nothing visible? If you click into the listbox,
can you select a row?
No, when it's empty I have the rowsource set to ""
Thanks
DS
 
D

DS

Rick said:
Do you have ColumnHeadings displayed in the ListBox? That will cause the
ListCount to always be at least 1.
No, I have the column heading off.
Thanks
DS
 
D

DS

Wayne said:
Is there any chance that you're leaving "blank" records in the listbox so
that there are 6 rows, but nothing visible? If you click into the listbox,
can you select a row?
PS, I Can select a row.
DS
 
D

DS

DS said:
No, I have the column heading off.
Thanks
DS
This worked for whatever reason.
If Me.ListSubMods.ListCount = 1 Then
Me.TxtAction = 0
ElseIf Me.ListSubMods.ListCount > 1 Then
Me.TxtAction = 6
End If

Thanks
DS
 
W

Wayne Morgan

I found that when the Row Source is blank (i.e. "") that the listbox acts as
if Column Headings is set to Yes and it will let you choose the first row,
even though there is nothing there to select.

When you said you were getting 6, you didn't actually specify where it was
coming from. The way you worded it was as if your ListCount was returning 6,
not the result of the If...Then statement. I would agree, given as mentioned
above, you would get 6 as a result of the If...Then statement if the Row
Source is set to "".
 
D

DS

Wayne said:
I found that when the Row Source is blank (i.e. "") that the listbox acts as
if Column Headings is set to Yes and it will let you choose the first row,
even though there is nothing there to select.

When you said you were getting 6, you didn't actually specify where it was
coming from. The way you worded it was as if your ListCount was returning 6,
not the result of the If...Then statement. I would agree, given as mentioned
above, you would get 6 as a result of the If...Then statement if the Row
Source is set to "".
Thanks Wayne, that is good information to know! I appreciate the feedback.
DS
 
Top