PC Review


Reply
Thread Tools Rate Thread

Dynamic Column Heading/Field Label

 
 
=?Utf-8?B?RGF2aWQ=?=
Guest
Posts: n/a
 
      17th Mar 2006
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
 
Reply With Quote
 
 
 
 
Duane Hookom
Guest
Posts: n/a
 
      17th Mar 2006
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



 
Reply With Quote
 
=?Utf-8?B?RGF2aWQ=?=
Guest
Posts: n/a
 
      17th Mar 2006
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

>
>
>

 
Reply With Quote
 
Duane Hookom
Guest
Posts: n/a
 
      17th Mar 2006
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

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?RGF2aWQ=?=
Guest
Posts: n/a
 
      17th Mar 2006
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
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Duane Hookom
Guest
Posts: n/a
 
      17th Mar 2006
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
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?RGF2aWQ=?=
Guest
Posts: n/a
 
      17th Mar 2006
Thanks. I'll give it a whirl.
--
David


"Duane Hookom" wrote:

> 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
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create dynamic column heading in Access form? kande_ian Microsoft Access Getting Started 0 25th Nov 2010 09:32 PM
column heading label Ron Microsoft Excel New Users 1 22nd Feb 2010 05:19 AM
Crosstab without column heading field Sharon Microsoft Access Queries 1 20th May 2009 02:51 AM
Crosstab - with one column heading and more than one value field Anj Microsoft Access Form Coding 4 24th Jul 2008 04:50 AM
Selecting a range from a dynamic column heading roadie.girl@gmail.com Microsoft Excel Discussion 2 9th Dec 2005 03:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:16 PM.