Rename a field in a query

mohobrien

Registered User.
Local time
Today, 12:42
Joined
Dec 28, 2003
Messages
58
I can't fathom this one. I have a field called Current Status in a table. When I run a query I want to rename the field like this
STATUS:Current Status

No matter what I do, the field remains Current Status. I have tried putting square brackets around like this STATUS:[Current Status] but Access throws them out. Every other field I have tried is no problem.
If I add another field in the query and try to call that STATUS:AnotherField, it renames that other field to Current Status, not STATUS. Even if I remove Current Status from the query!
Any body understand what is happening?
 
Where are you attempting to do this?

It should be fairly easy in the QBE grid

Under the Field area:
MyNewName:My Current Field


In SQL view:

Select [My Current Field] As MyNewName

etc.
 
That is where I am doing this. I have done this hundreds of times before. I am wondering if STATUS or Current is a reserved word.
 
Shouldn't putting brackets around like this [Current Status] allow it to work? Access won't accept the brackets.
 
Shouldn't putting brackets around like this [Current Status] allow it to work? Access won't accept the brackets.

Can you post your database (you can clear all of the data out using my free reset tool) and then say which query you are trying this on. Then we can see what is happening.
 
I stripped everything except a bit of a table and a query.
 

Attachments

Okay, that was easy.

1. You need to remove the CAPTION from the field in the table.

2. Then delete the entire field from the query and do it over.

It should work.

Also a side note, you should not define lookups for fields at table level. See here for why.
 
After using access daily for ten years I find that there is a property called Caption. That's embarrassing. Thanks Bob. I'll read what you suggested.
 
After using access daily for ten years I find that there is a property called Caption. That's embarrassing. Thanks Bob. I'll read what you suggested.

Hey don't feel bad. I've been using Access and developing in it for almost 14 years and I keep learning new things about it. There is a lot to learn and you don't necessarily touch on everything as you go along until one day - BOOM! you find you do. :)
 
Re: Rename a field in a query - how when a caption ??

Does anyone know how to do the rename of a field with caption without using the caption name or the name of the field.

I have a user that wants a different name on the output other than the table field name and different than the caption.

I am have not found an way, yet.
:rolleyes:

I said I could so I will. I am guessing the only way would be to create a new table from the query??

Russ
 
The fix I found is this, where old name is the string.
newname: StrConv(string, conversion [, LCID ] )
Russ
 
A "solution":
So, I have a field "FieldWithCaption" with caption "FieldCaption"
Now, I create a query in QueryDesign view:
A:FieldWithCaption | NewFieldName:[A]

This work but, unfortunately, is no way to hide the first field.
Of course, if a Form or a report is based on this query, no matter.

If you need to show a query, the only one solution I can find is to design a new query, based on the previous one, where to drag only the NewFieldName.
 
Thankfully, Captions are much more intelligently implemented in A2010 but for earlier versions they caused almost as many problems as table level lookup fields. Your user shouldn't be looking at tables directly so Captions aren't doing anything but getting in the way in your version of Access. I would suggest removing them. In the cases where you want to export a query, use Alias' to rename the fields to more user friendly names.
 

Users who are viewing this thread

Back
Top Bottom