Counting records in Access dB from VB (1 Viewer)

Howlsta

Vampire Slayer
Local time
Today, 09:49
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
 

Fizzio

Chief Torturer
Local time
Today, 09:49
Joined
Feb 21, 2002
Messages
1,885
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

Top Bottom