RecordCount

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
 
G

Graham Mandeno

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.
 
J

JamesJ

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
 

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

Top