Hallo. If quite often find myself using code like:
Dim qry as QueryDef
Dim rc as Recordset
Dim sqlstr as string
Dim Count as Integer
sqlstr="SELECT COUNT([My_Table].*) AS Count FROM [My_Table] WHERE [My_Table].[Flag]=True;"
set qry=CurrentDb.CreateQueryDef("",sqlstr)
set rc=qry.OpenRecordset
rc.MoveFirst
Count=rc!Count
This is fine, but would there be a way of running the query or SQL (like DoCmd.RunSQL) in a way that just reads the result into a variable (in this case the integer Count)?
Thanks,
Douglas
Common sense is what tells you the world is flat.
Dim qry as QueryDef
Dim rc as Recordset
Dim sqlstr as string
Dim Count as Integer
sqlstr="SELECT COUNT([My_Table].*) AS Count FROM [My_Table] WHERE [My_Table].[Flag]=True;"
set qry=CurrentDb.CreateQueryDef("",sqlstr)
set rc=qry.OpenRecordset
rc.MoveFirst
Count=rc!Count
This is fine, but would there be a way of running the query or SQL (like DoCmd.RunSQL) in a way that just reads the result into a variable (in this case the integer Count)?
Thanks,
Douglas
Common sense is what tells you the world is flat.