Can field names be changed with a query?

P

Pat

I've got a sequence of queries that culminates in a final make-table query.
I would like to change the fieldnames with the final query, producing the
table with new fieldnames. Is there a way to do this?

Thanks,
Patrick
 
J

Jerry Whittle

Sure. In the field name put what you want to see in the new table like so:

NewName: OldFieldName

What is before the colon ( : ) should be the new field name.
 
P

Pat

Thanks Jerry. Can this same technique also be used to produce a new query
with new field names? So, for example if I have a sequence of select queries
in which the fieldnames have grown too long (which I'm also having trouble
with), could I insert a select query that simply changes field names before
carrying on with further select queries in the sequence?

Patrick
 
J

John W. Vinson

I've got a sequence of queries that culminates in a final make-table query.
I would like to change the fieldnames with the final query, producing the
table with new fieldnames. Is there a way to do this?

Thanks,
Patrick

You can assign an alias to any field in a query by preceding the fieldname or
expression with the alias, followed by a colon:

NewName: [oldfieldname]

will assign the name Newname to the value in oldfieldname.

In SQL, this corresponds to

SELECT oldfieldname AS NewName FROM ...

The alias will be used as the new fieldname in your maketable query.

Note that MakeTable queries are in practice *very rarely needed*, just be sure
that you actually do need to store this information redundantly!

John W. Vinson [MVP]
 
P

Pat

Thanks John for the advice. I'll take a look at whether I really need the
table.

Patrick

John W. Vinson said:
I've got a sequence of queries that culminates in a final make-table query.
I would like to change the fieldnames with the final query, producing the
table with new fieldnames. Is there a way to do this?

Thanks,
Patrick

You can assign an alias to any field in a query by preceding the fieldname or
expression with the alias, followed by a colon:

NewName: [oldfieldname]

will assign the name Newname to the value in oldfieldname.

In SQL, this corresponds to

SELECT oldfieldname AS NewName FROM ...

The alias will be used as the new fieldname in your maketable query.

Note that MakeTable queries are in practice *very rarely needed*, just be sure
that you actually do need to store this information redundantly!

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top