Access 2002 on Win98 at least, not tested elsewhere:
Bug: The ListCount property of an unbound listbox may be incorrect if you
use column heads.
Model: Set up a simple database with two simple tables (I used employer and
person). Create a bound form based on the employer table, with a txtName
textbox, a txtID textbox, and an unbound listbox to the employer table
["SELECT * FROM employer"]. Add a second unbound listbox for the person
table, with column heads ["SELECT * FROM person"]. Then add at least one
employer to the employer table.
Add a Find button with the following code:
Private Sub btnFind_Click()
Me.txtID.SetFocus
DoCmd.FindRecord Me.lstEmployers.Value
MsgBox Me.lstPersons.ListCount
End Sub
Open the form, and select the employer in the employer listbox. Hit the Find
button. The first time, the MsgBox will incorrectly report the ListCount as
0. According to Help, it should show "1", since it is a Listbox based on a
Query with column heads. Further, after pressing the Find button several
times (3- 10 or so, depending on how fast you press the button!), the
MsgBox will begin to correctly report "1".
Damn irritating if you've been relying on the ListCount property.
Darryl Kerkeslager