You got it.
There is a sample MDB at
http://www.rogersaccesslibrary.com/O...p#Hookom,Duane which
shows how to dynamically set a subform to a query.
--
Duane Hookom
MS Access MVP
--
"David" <(E-Mail Removed)> wrote in message
news:5831EB2E-4AE3-4F06-BAB8-(E-Mail Removed)...
> Thanks Duane.
>
> So, if I follow your thinking:
>
> I pass the query name as pstrQuery
> I pass the desired SQL syntax as pstrSQL?
>
> Of course, I will have needed to create the SQL syntax prior to this call,
> but I could then use the query as the datasource for the Datasheet form?
>
>
>
> --
> David
>
>
> "Duane Hookom" wrote:
>
>> You can use DAO to modify the SQL property of a saved query. I use this
>> basic function in most of my MDBs. You would need to build your sql
>> syntax
>> based on your needs and then use this function to update your saved
>> query.
>>
>> Sub ChangeSQL(pstrQuery As String, pstrSQL As String)
>> Dim db As DAO.Database
>> Dim qd As DAO.QueryDef
>> Set db = CurrentDb
>> Set qd = db.QueryDefs(pstrQuery)
>> qd.SQL = pstrSQL
>>
>> Set qd = Nothing
>> Set db = Nothing
>>
>> End Sub
>>
>> --
>> Duane Hookom
>> MS Access MVP
>> --
>>
>> "David" <(E-Mail Removed)> wrote in message
>> news:F0C2B015-8411-47C4-83D1-(E-Mail Removed)...
>> > Duane,
>> >
>> > Thanks. Any code samples you can provide for this?
>> > --
>> > David
>> >
>> >
>> > "Duane Hookom" wrote:
>> >
>> >> I think you would need to use code to modify the SQL property of a
>> >> saved
>> >> query.
>> >>
>> >> --
>> >> Duane Hookom
>> >> MS Access MVP
>> >> --
>> >>
>> >> "David" <(E-Mail Removed)> wrote in message
>> >> news:31C4D581-1D62-401D-AE14-(E-Mail Removed)...
>> >> > Hello,
>> >> >
>> >> > I have a query as a data source into a Datasheet Form.
>> >> >
>> >> > I am trying to have a field in one source of my query, that source
>> >> > being a
>> >> > query, become the column heading or field label of a field in my
>> >> > other
>> >> > source
>> >> > of the query, which is a table.
>> >> >
>> >> > The syntax: [qryCriteriaHeadings]![CriteriaDesc1]:
>> >> > [MasterCriteria]![CriteriaValue1] does not yield the result I
>> >> > expect,
>> >> > in
>> >> > fact, I get an error saying [qryCriteriaHeadings]![CriteriaDesc1] is
>> >> > not a
>> >> > valid name.
>> >> >
>> >> > Is there a way to do this using QBE?
>> >> >
>> >> > Thanks,
>> >> > --
>> >> > David
>> >>
>> >>
>> >>
>>
>>
>>