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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting Query

Status
Not open for further replies.

Dannybe2

Programmer
Jan 31, 2001
136
GB
How do I write some code to count the number of records in a query. I have a program with records that gradually decreases, and I have a button that goes to a random record - the problem is that as the number of records decreases, the random search picks out records that have disappeared from the query and it crashes.

How do I count how many records there are in a query at any time?

Thanks,
Dan
 
Dim db as database
Dim rst as dao.recordset
Dim strSQL as string
Dim lng as long

Set db = currentdb

strSQL = "SELECT * FROM [tblName];"
Set rst = db.openrecordset(strSQL)

rst.movelast
lng = rst.recordcount
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top