Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wrong number of records reported

Status
Not open for further replies.

HelgeLarsen

Programmer
Mar 18, 2004
16
DK
I have made a rather comprehensive VBA routine that documents the content of Access databases, especially tables and queries. I find the number of records in a table by:
For Each aTabDef In CurrentDb.TableDefs
aRecordCount = aTabDef.RecordCount
Next aTabDef

However, I have recognized that sometimes the number of records is wrong - until I have made a 'Compact and Repair database'. Should this be expected?

A 'Compact and Repair database' might take quite a time for large databases. Therefore, can I do something else to update the record count?

(Actually, I have only seen wrong record counts when running a database that I have just received from a partner using German setup, and then opens it on my PC using English setup - although in Denmark.)



________________________
Helge Larsen
 
To get an accurate count (even for linked tables):
Code:
For Each aTabDef In CurrentDb.TableDefs
    aRecordCount = DCount("*", "[" & aTabDef.Name & "]")
Next aTabDef

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top