setting the record set of a Query

businessman

Registered User.
Local time
Today, 00:15
Joined
Jun 19, 2006
Messages
79
Can i edit a query to equal a SQL string just like i do for my reports? for my reports i say:

Code:
                   DoCmd.OpenReport "Check Filter", acViewDesign, , , acHidden
                   Reports![Check Filter].RecordSource = strRecordSource
                   DoCmd.Close acReport, "Check Filter", acSaveYes

i tried to say
Code:
                   DoCmd.OpenQuery "Query1", acViewDesign, acEdit
                   Queries![Query1].RecordSource = strRecordSource
                   DoCmd.Close acQuery, "Query1", acSaveYes

i get an error in the middle line...how do i do what i'm trying to do?
 
Queries don't seem to have a recordsource property, but they do have a filter property. (I am assuming that you want to control the WHERE clause of the query). If you are trying to control the whole SQL statement, you might try dealing with it as a query def.
 
Last edited:
For the record, a recordsource is basically the results of a query. A query can be used as a recordsource, and in reality, even when you use a table as a recordsource Access really uses a query on the table behind the scenes.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom