ListCount

  • Thread starter Thread starter DS
  • Start date Start date
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
 
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?
 
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.
 
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
 
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
 
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
 
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
 
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 "".
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Complex If Statement 6
Can someone check my code? 2
Code Confusion 10
Listbox ListCount Zero or One?? 2
Field Value 3
Listbox .Selected=False won't work 7
ListBox Question 4
List Boxes - Access 2003 0

Back
Top