J
John C.
I need to count the number of records in a table, can
anyone help or point me in the right direction?
anyone help or point me in the right direction?
Set MyRS = MyDB.OpenRecordset("tblname", dbOpenDynaset)
Tim Ferguson said:Opening a dynaset to count the records is incredibly wasteful of system
resources, as well as inconsiderate to other users who will find all the
records locked... If you have to use this method, at least use a Forward
Only Snapshot.
Then again, you just might not think it is sensible to cart an entire 350MB
table across the network when all you want to end up with is a single
integer (4 bytes). The COUNT(*) function, or its DCount() function
shortcut, allows the work to take place on the server and reduces
drastically the network traffic and resources in the workstation.
TC said:What's more, msoft make a few coy references to how SELECT COUNT(*) is
Rushmore optimized. Compared to SELECT COUNT(something_else), which
isn't.
Tim Ferguson said:and they give different answers. COUNT(*) returns the record count, while
COUNT(Elephant) only counts the rows WHERE Elephant IS NOT NULL (have to
confess I haven't checked this so feel free to abuse me for it if I am
wrong).