Count How Many Records on Form?

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

I need code to count the number of records on my form.
Cant use the built in counter because of needing this for code purposes.
Form name is Time and Hours
Table name is Hours
 
To have the number of records displayed on your form, you can use:

nbRec = Me.Recordset.RecordCount

However this property is considered by Access as 2nd priority, so it as
refreshed at the end of the loading of the form.
So if you type the code below in the form's loading event, you'll get 0 even
if you see more than 0 record.

To avoid that, you can force Access to refresh the propriety using:

Me.RecordsetClone.MoveLast
Me.RecordsetClone.MoveFirst
nbRec = Me.Recordset.RecordCount
 
=Abs([EmployeeID]) Counts the number of employees i have on the form
However it counts the whole table and not just the records on the form i am
on.
Example, this is a sub-form on my main form, so it shows only the records
for the main form
which in this case is three (3)
However the above code counts the total number od times the employee is in
the underlying table
I need to count either the records for this sub-form or the number of
employees
EmployeeID is a combo lookup that is based on employeeid , but shows the
employees name

How can i do this???
 
Back
Top