Can I query a DAO recordset

iampaul

Registered User.
Local time
Today, 15:58
Joined
Apr 19, 2005
Messages
14
Is it possible to query a DAO recordset once it has been created in VBA. Currently I create a recordset and use it for a few things, but It would be useful to be able to run a few more bits of SQL against it to check some other things. The table it is created from is large and it takes several seconds to creatye the recordset. I could insert the records into a table and query that, but would prefer to it in VBA as it gives me more flexibility.

The code I use is something like this:

strSQL = "SELECT * from table WHERE field = '" & ctlCombo & "';"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
If Not rs.EOF Then
rs.MoveLast
End If
lngRecordCount = rs.RecordCount

What i would then like to be able to do is

select count * from rs where field 2 = 'abc' etc.
 
you can use
rs.FindFirst
or
rs.Seek

Seek is if you have any Indexes on your table. Use findfirst if you dont.

Check the help for more detailed info
 
Could you save a query that references the desired control (or controls) to get the variable parameters, and then run further (dynamically coded) sql against that query (like a nested query) for what you need ?
 

Users who are viewing this thread

Back
Top Bottom