Field Name in Query Results

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

Guest

I've run a query but in the results, one of the fields is labeled "Field0"
How can I change this to the name of the actual field in the table/query?
 
You probably have the same field name elsewhere in the query columns. Each
field/column name must be unique.
 
Eric said:
I've run a query but in the results, one of the fields is labeled "Field0"
How can I change this to the name of the actual field in the table/q

First of all, the problem is probably caused by the actual fieldname
being illegal for some reason. Maybe you have an invalid character or
something. If so, make sure you make the display name legal. For
example, remove any funny characters from the display name. To fix:

IF you are in the query builder, and your field is called This/Is#Wrong

then you want

This_is_wrong:[This/is#Wrong]. This just changes the name to one you
like better.

IF you are talking SQL,
SELECT [table_name_here]![This/Is#wrong] AS This_is_wrong

does the same thing. All you are doing is substituting the name you
like for the one that Access doesn't.
 
Hi,


Can't you use an alias, in your context:


SELECT this AS that
FROM ...



and what would have been under the field name [this] will now be under the
field name [that]




Hoping it may help,
Vanderghast, Access MVP
 
There is a duplicate field name but it appears on its own. No matter how
many times I delete it, it keeps coming back.

Isn't there a way to put the name of the field in brackets or something so
that that is what appears?
 
Phil,

Alas the field name is not illegal because I took it from the drop-down box.
The name of the field is "Detail." I tried Detail:[Detail] but in the Query
results, it still says "Field0".

Any other suggestions?

Eric

Phil said:
Eric said:
I've run a query but in the results, one of the fields is labeled "Field0"
How can I change this to the name of the actual field in the table/q

First of all, the problem is probably caused by the actual fieldname
being illegal for some reason. Maybe you have an invalid character or
something. If so, make sure you make the display name legal. For
example, remove any funny characters from the display name. To fix:

IF you are in the query builder, and your field is called This/Is#Wrong

then you want

This_is_wrong:[This/is#Wrong]. This just changes the name to one you
like better.

IF you are talking SQL,
SELECT [table_name_here]![This/Is#wrong] AS This_is_wrong

does the same thing. All you are doing is substituting the name you
like for the one that Access doesn't.
 
Michel,

Where do I type this alias? The field name is "Detail" so I put SELECT
Detail AS Detail FROM Detail in the top line of the query but it says the
expression has errors.

Eric

Michel Walsh said:
Hi,


Can't you use an alias, in your context:


SELECT this AS that
FROM ...



and what would have been under the field name [this] will now be under the
field name [that]




Hoping it may help,
Vanderghast, Access MVP

Eric Rodriguez said:
I've run a query but in the results, one of the fields is labeled "Field0"
How can I change this to the name of the actual field in the table/query?
 
Hi,



Using the same alias name than the original name is uncommon, at least. From
the query designer, you can define an alias with the syntax:


Expr0001: MyField


in the first line. The produced SQL will then be like

SELECT ... MyField As Expr0001 ... FROM ...


If you are using MS SQL Server, you can use an alias with the same name as
the one of an existing field:


SELECT f1 AS f2, f2 as f1 FROM Orders

because MS SQL Server consider aliases only at the end of the process. With
Jet, you cannot, since Jet considers aliases in the middle of the process:


SELECT f1 + f2 As MySum, MySum / 2 As MyMean FROM somewhere


is possible in Jet, note that the alias mySum is re-used in an expression to
the right of its definition, but that is not allowed at all in MS SQL
Server. That also means that Jet does not like ambiguity, if an alias is the
same than an existing field (while with MS SQL Server, the co-existence of
the two, the original field name and the alias, is impossible, at a given
point in time).




Hoping it may help,
Vanderghast, Access MVP


Eric Rodriguez said:
Michel,

Where do I type this alias? The field name is "Detail" so I put SELECT
Detail AS Detail FROM Detail in the top line of the query but it says the
expression has errors.

Eric

Michel Walsh said:
Hi,


Can't you use an alias, in your context:


SELECT this AS that
FROM ...



and what would have been under the field name [this] will now be under
the
field name [that]




Hoping it may help,
Vanderghast, Access MVP

message
I've run a query but in the results, one of the fields is labeled
"Field0"
How can I change this to the name of the actual field in the
table/query?
 
Sorry, Charlie, but Detail can be an illegal name. (reserved word)
Why, I don't know, ask Bill. Try substituting "Detail" with "Details"
and see if that makes a difference. Betcha it does.
Phil,

Alas the field name is not illegal because I took it from the drop-down box.
The name of the field is "Detail." I tried Detail:[Detail] but in the Query
results, it still says "Field0".

Any other suggestions?

Eric

:

Eric Rodriguez wrote:

I've run a query but in the results, one of the fields is labeled "Field0"
How can I change this to the name of the actual field in the table/q

First of all, the problem is probably caused by the actual fieldname
being illegal for some reason. Maybe you have an invalid character or
something. If so, make sure you make the display name legal. For
example, remove any funny characters from the display name. To fix:

IF you are in the query builder, and your field is called This/Is#Wrong

then you want

This_is_wrong:[This/is#Wrong]. This just changes the name to one you
like better.

IF you are talking SQL,
SELECT [table_name_here]![This/Is#wrong] AS This_is_wrong

does the same thing. All you are doing is substituting the name you
like for the one that Access doesn't.
 

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

Back
Top