Counting records in Access dB from VB

Howlsta

Vampire Slayer
Local time
Today, 04:30
Joined
Jul 18, 2001
Messages
180
I'm trying to count the number of records in a table, normally i'd do a dcount. But I'm trying to correct a problem in some VB code, which appends new data to an Access dB.
How can I code it to count the records in the database from VB?

cheers

Rich
 
Why can't you still use DCount?
You could use a recordset if not DCount

Dim MyDb as Database, MyRs as Recordset
Set MyDb = CurrentDb
Set MyRs = MyDb.OpenRecordset("NameOfTable", dbOpenSnapshot)
MyRs.MoveLast
MsgBox MyRs.RecordCount
Set MyRs = Nothing

HTH
 

Users who are viewing this thread

Back
Top Bottom