Well, almost. You need to move to the last record in the recordsource in order to get the proper count at least in the DAO provided by zevw. If you run that code when the form opens, it will only return the number of records already loaded... which could be 0... but it will ALWAYS be less than the total number of records... unless of course the recordcount is zero.
Try this:
Dim dbs as Database
Dim rst as recordset
Dim cnt as long '(Always strong-type your data types)
set dbs = currentdb
set rst = dbs.OpenRecordset("<Table Name>"
rst.MoveLast
cnt = rst.RecordCount
'Always close your object references
rst.close
set rst =nothing
dbs.close
set db = nothing
this has to be based on a table... not a form or report... it probably worked for your form since it may have the same name as your table... just look at the record source for the report and reference that in your
set rs
line...
--James junior1544@jmjpc.net
Life is change. To deny change is to deny life.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.