Name column with function????

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there some way to use functions to name column labels. I have columns
that use the current year plus some text as the label.

example: 2005 Returns:( IIf([net sales] is null, ..........etc)


I have quite a few of these and would like it if I didn't have to go in and
manually change the column labels. Is there a way to do this?
 
Dear Billy:

Column names can be controlled using aliases. Of course, they cannot be
changed during the execution of the query, but must be completely determined
when it starts.

Under what conditions do you want to change some column names?

You would have to code the generation of the query text using the generated
names. They cannot be generated by the query itself (exception: a stored
procedure can generate query code and execute it).

So, you want to generate the name "2005 Returns", perhaps making it 2006
Returns when the query is for 2006. Is that the idea?

Tom Ellison
 
Yes, it's the column alias that I want to change. There are probably 20 of
them that have the year plus some text as the alias, and I can't think of a
way to change all of them except by typing in each one manually.

Tom Ellison said:
Dear Billy:

Column names can be controlled using aliases. Of course, they cannot be
changed during the execution of the query, but must be completely determined
when it starts.

Under what conditions do you want to change some column names?

You would have to code the generation of the query text using the generated
names. They cannot be generated by the query itself (exception: a stored
procedure can generate query code and execute it).

So, you want to generate the name "2005 Returns", perhaps making it 2006
Returns when the query is for 2006. Is that the idea?

Tom Ellison


BillyRogers said:
Is there some way to use functions to name column labels. I have columns
that use the current year plus some text as the label.

example: 2005 Returns:( IIf([net sales] is null, ..........etc)


I have quite a few of these and would like it if I didn't have to go in
and
manually change the column labels. Is there a way to do this?
 
Dear Billy:

I believe my response did outline a way to do it. Please re-read it.

Tom Ellison


BillyRogers said:
Yes, it's the column alias that I want to change. There are probably 20
of
them that have the year plus some text as the alias, and I can't think of
a
way to change all of them except by typing in each one manually.

Tom Ellison said:
Dear Billy:

Column names can be controlled using aliases. Of course, they cannot be
changed during the execution of the query, but must be completely
determined
when it starts.

Under what conditions do you want to change some column names?

You would have to code the generation of the query text using the
generated
names. They cannot be generated by the query itself (exception: a
stored
procedure can generate query code and execute it).

So, you want to generate the name "2005 Returns", perhaps making it 2006
Returns when the query is for 2006. Is that the idea?

Tom Ellison


BillyRogers said:
Is there some way to use functions to name column labels. I have
columns
that use the current year plus some text as the label.

example: 2005 Returns:( IIf([net sales] is null, ..........etc)


I have quite a few of these and would like it if I didn't have to go in
and
manually change the column labels. Is there a way to do this?
 
Sorry Tom, i don't quite understand. Suppose you wanted the colum title to be
todays date no matter what day you ran the query. How would you code that?
I've tried date():fieldname_or_expression and the column name turns
out to be a string 'date()'.


"You would have to code the generation of the query text using the generated
names. They cannot be generated by the query itself (exception: a stored
procedure can generate query code and execute it). "



Tom Ellison said:
Dear Billy:

I believe my response did outline a way to do it. Please re-read it.

Tom Ellison


BillyRogers said:
Yes, it's the column alias that I want to change. There are probably 20
of
them that have the year plus some text as the alias, and I can't think of
a
way to change all of them except by typing in each one manually.

Tom Ellison said:
Dear Billy:

Column names can be controlled using aliases. Of course, they cannot be
changed during the execution of the query, but must be completely
determined
when it starts.

Under what conditions do you want to change some column names?

You would have to code the generation of the query text using the
generated
names. They cannot be generated by the query itself (exception: a
stored
procedure can generate query code and execute it).

So, you want to generate the name "2005 Returns", perhaps making it 2006
Returns when the query is for 2006. Is that the idea?

Tom Ellison


Is there some way to use functions to name column labels. I have
columns
that use the current year plus some text as the label.

example: 2005 Returns:( IIf([net sales] is null, ..........etc)


I have quite a few of these and would like it if I didn't have to go in
and
manually change the column labels. Is there a way to do this?
 
Dear Billy:

My solution has nothing to do with the query design view you are seeing.
Start by changing the column name manually, like:

date():fieldname_or_expression

Change this to:

02/02/2006:fieldname_or_expression

Go to the SQL view of the query with this change made. You will need to
write VBA code in a module to insert the date into the SQL string where the
02/02/2006 is. Then execute the SQL from within that VBA procedure, or
assign it as the RecordSource or ControlSource where it is needed. This can
be, for instance, done for a Report or Form, or any control that accepts a
query source.

If this seems rather mysterious, then perhaps you are not up to coding this.

Tom Ellison


BillyRogers said:
Sorry Tom, i don't quite understand. Suppose you wanted the colum title to
be
todays date no matter what day you ran the query. How would you code
that?
I've tried date():fieldname_or_expression and the column name
turns
out to be a string 'date()'.


"You would have to code the generation of the query text using the
generated
names. They cannot be generated by the query itself (exception: a stored
procedure can generate query code and execute it). "



Tom Ellison said:
Dear Billy:

I believe my response did outline a way to do it. Please re-read it.

Tom Ellison


BillyRogers said:
Yes, it's the column alias that I want to change. There are probably
20
of
them that have the year plus some text as the alias, and I can't think
of
a
way to change all of them except by typing in each one manually.

:

Dear Billy:

Column names can be controlled using aliases. Of course, they cannot
be
changed during the execution of the query, but must be completely
determined
when it starts.

Under what conditions do you want to change some column names?

You would have to code the generation of the query text using the
generated
names. They cannot be generated by the query itself (exception: a
stored
procedure can generate query code and execute it).

So, you want to generate the name "2005 Returns", perhaps making it
2006
Returns when the query is for 2006. Is that the idea?

Tom Ellison


Is there some way to use functions to name column labels. I have
columns
that use the current year plus some text as the label.

example: 2005 Returns:( IIf([net sales] is null, ..........etc)


I have quite a few of these and would like it if I didn't have to go
in
and
manually change the column labels. Is there a way to do this?
 
Back
Top