RecordCount

  • Thread starter Thread starter JamesJ
  • Start date Start date
J

JamesJ

Trying to show the number of record in txtCount using the following:

If Me.NewRecord Then

txtCount = "0 Item(s)"

Else

txtCount = Me.RecordsetClone.RecordCount & " Item(s)"

End If

The form is based on a table and has a list box who's rowsource is the same
table.
The problem is when the form opens the textbox shows only 1 Item until I
make a
selection in the listbox then it shows the proper number.

Any ideas here?

Thanks,
James
 
Hi James

Where have you got this code? And why do you want to show zero items if the
current focus is on a new record?

I suggest you set the ControlSource of txtCount to either:
=[Form].[RecordsetClone].[RecordCount]
or
=[ListboxName].[ListCount]

This *should* work without any code, but you might need to add:
txtCount.Requery
to your Form_Current event procedure.
 
Thanks much. The Expression for the Form returns a #Name?
But the one for the listbox works fine.
Don;t know where I got that code from but I set the 0 items myself.
Don't know why.

James

Graham Mandeno said:
Hi James

Where have you got this code? And why do you want to show zero items if
the current focus is on a new record?

I suggest you set the ControlSource of txtCount to either:
=[Form].[RecordsetClone].[RecordCount]
or
=[ListboxName].[ListCount]

This *should* work without any code, but you might need to add:
txtCount.Requery
to your Form_Current event procedure.
--
Good Luck :-)

Graham Mandeno [Access MVP]
Auckland, New Zealand

JamesJ said:
Trying to show the number of record in txtCount using the following:

If Me.NewRecord Then

txtCount = "0 Item(s)"

Else

txtCount = Me.RecordsetClone.RecordCount & " Item(s)"

End If

The form is based on a table and has a list box who's rowsource is the
same table.
The problem is when the form opens the textbox shows only 1 Item until I
make a
selection in the listbox then it shows the proper number.

Any ideas here?

Thanks,
James
 
Back
Top