OpenRecordset

  • Thread starter Thread starter Rafael Bélanger via AccessMonster.com
  • Start date Start date
R

Rafael Bélanger via AccessMonster.com

Currently i have a dao.recordset called rsWhatever.
When i want to set the query in the rsWhatever.OpenRecordset(strQuery), ive
always done a query from a table, which make sense but can i do a query
from a query i have saved in my database like this :

dim rsWhatever as dao.recordset

set rsWhatever = currentdb.OpenRecordset("SELECT * FROM [Query] WHERE
this=this and that=that and ....")

This way i can optain filtered results from the query i have, i know i
could put the entire query in one sql statement but i already my results in
one query and i only need 1 field of that query.

Mayb i could work it out with a querydef but i have no clue how it works,
but i do not mind going threw another way if i have to, if anybody could
help it would be appreciated.

Thank
Rafael
 
Rafael said:
Currently i have a dao.recordset called rsWhatever.
When i want to set the query in the
rsWhatever.OpenRecordset(strQuery), ive always done a query from a
table, which make sense but can i do a query from a query i have
saved in my database like this :

dim rsWhatever as dao.recordset

set rsWhatever = currentdb.OpenRecordset("SELECT * FROM [Query] WHERE
this=this and that=that and ....")[snip]

It would have taken less time to try it then it did to post the question.

The answer is yes.
 
I did try it thats why im posting it, wasnt working...still isnt, thx anyway
 
Rafael said:
I did try it thats why im posting it, wasnt working...still isnt, thx
anyway

Are you trying to open a Table type RecordSet? Note the last sentence from
the Access 97 Help file...

A String specifying the source of the records for the new Recordset. The
source can be a table name, a query name, or an SQL statement that returns
records. For table-type Recordset objects in Microsoft Jet databases, the
source can only be a table name.

If so, just specify Dynaset as the type instead.
 
Back
Top