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

how to count records of query defined in vba

Status
Not open for further replies.

Davide77

Technical User
Mar 6, 2003
166
0
0
CH
Hallo, I have a query defined in vba code:

Dim strsql as string
strSql = "SELECT [Qry_Room].[Room] FROM [Qry_Room] WHERE [Qry_Room].[Day]=" & Format(CDate(giorno), "dd-mm-yyyy") & ";"

how do i count the number of record of it?

i tried with the dcount:

RecordQuantity = DCount(strsql, "qry_Room")


but doesn't work

any suggestion?
 
Hi

you can open assign the query to a recordset then get the .RecordCount value

dim rst as adodb.recordset

set rst = new adodb.recordset

rst.open "yourSelectstatement", currentproject.connection
RecordQuantity = .RecordCount

rst.close
set rst = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top