Set the RecordSource of the Form to the SQL that you would use to open the
Recordset. A Form's RecordSource is not a Recordset, it is a string Value
that is used to obtain the Records. It can be either the name of a saved
Query or an SQL statement (which by definition is text).
Larry Linson
Microsof Access MVP
"deko" <dj****@hotmail.com> wrote in message
news:az*****************@newssvr27.news.prodigy.co m...
I have several stored queries that provide views based on user selection -
selection criteria is stored in strPxSx, and the query called would then
be "qrySearch24" or "qrySearch19", for example.
I'm somewhat of a rookie when it comes to working with Recordsets, but
this is what I'm trying to do:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Set dbs = CurrentDb
Set rst = dbs.QueryDefs("qrySearch" & strPxSx).OpenRecordset
Me.RecordSource = dbs.QueryDefs("qrySearch" & strPxSx).OpenRecordset
?????????
Me.Requery
The desired outcome is to use the Recordset as the RecordSource for the
Form - so only records that are found in qrySearch24 are displayed in the
Form.
Another (much slower) way to do this is:
strSqlFilter = "[Entity_ID] IN (SELECT DISTINCT Entity_ID FROM qrySearch"
& strPxSx & ")"
Me.Filter = strSqlFilter
Me.FilterOn = True
Can anyone help me do this with a recordset?
Thanks in advance!