A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Querying using SQL statement



 
 
Thread Tools Display Modes
  #1  
Old February 7th, 2010, 10:31 PM posted to microsoft.public.access.queries
Joe[_22_]
external usenet poster
 
Posts: 18
Default Querying using SQL statement

Hi

Using an expression as follows...

SELECT IDCustomer AS Code, Name, Address FROM Customers

....the AS clause doesn't work in Access 2007.

Running the query, the column caption remains IDCustomer.

What is the problem? Why this happens?

Is there any solution (except back to 2003)?

Thanks in advance for your help.

Joe


  #2  
Old February 7th, 2010, 11:19 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Querying using SQL statement

On Sun, 7 Feb 2010 20:31:19 -0200, "Joe" wrote:

Hi

Using an expression as follows...

SELECT IDCustomer AS Code, Name, Address FROM Customers

...the AS clause doesn't work in Access 2007.

Running the query, the column caption remains IDCustomer.

What is the problem? Why this happens?

Is there any solution (except back to 2003)?

Thanks in advance for your help.

Joe

This is probably another reserved name. 2007 is much pickier about using
reserved words (Code, Date, Order, etc.) as fieldnames.

Does it work if you use AS CustomerCode? Or you might try

AS [code]

--

John W. Vinson [MVP]
  #3  
Old February 8th, 2010, 12:02 AM posted to microsoft.public.access.queries
Joe[_22_]
external usenet poster
 
Posts: 18
Default Querying using SQL statement

Hi John

The name Code was just an example.

Anything I type, a regular text or even a name - Robert - for example, it
doesn't work.

I'm using a Access 2007 in Brazilian-portuguese version.

This customized version could be the problem? In positive case, is there a
solution?

Thanks in advance for your time and answer.

Joe






"John W. Vinson" escreveu na mensagem
...
On Sun, 7 Feb 2010 20:31:19 -0200, "Joe" wrote:

Hi

Using an expression as follows...

SELECT IDCustomer AS Code, Name, Address FROM Customers

...the AS clause doesn't work in Access 2007.

Running the query, the column caption remains IDCustomer.

What is the problem? Why this happens?

Is there any solution (except back to 2003)?

Thanks in advance for your help.

Joe

This is probably another reserved name. 2007 is much pickier about using
reserved words (Code, Date, Order, etc.) as fieldnames.

Does it work if you use AS CustomerCode? Or you might try

AS [code]

--

John W. Vinson [MVP]



  #4  
Old February 8th, 2010, 01:49 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Querying using SQL statement

On Sun, 7 Feb 2010 22:02:08 -0200, "Joe" wrote:

Hi John

The name Code was just an example.

Anything I type, a regular text or even a name - Robert - for example, it
doesn't work.

I'm using a Access 2007 in Brazilian-portuguese version.

This customized version could be the problem? In positive case, is there a
solution?

Thanks in advance for your time and answer.


Odd! I have a database with a ton of queries, many of which use aliases, and
they work fine in 2007.

Try leaving out the keyword AS - it's optional in at least some contexts.

Perhaps you could post the actual complete SQL that's giving you the error.
--

John W. Vinson [MVP]
  #5  
Old February 8th, 2010, 02:03 AM posted to microsoft.public.access.queries
Duane Hookom
external usenet poster
 
Posts: 7,177
Default Querying using SQL statement

Do you have a Caption property defined in the table design?

--
Duane Hookom
Microsoft Access MVP


"Joe" wrote:

Hi John

The name Code was just an example.

Anything I type, a regular text or even a name - Robert - for example, it
doesn't work.

I'm using a Access 2007 in Brazilian-portuguese version.

This customized version could be the problem? In positive case, is there a
solution?

Thanks in advance for your time and answer.

Joe






"John W. Vinson" escreveu na mensagem
...
On Sun, 7 Feb 2010 20:31:19 -0200, "Joe" wrote:

Hi

Using an expression as follows...

SELECT IDCustomer AS Code, Name, Address FROM Customers

...the AS clause doesn't work in Access 2007.

Running the query, the column caption remains IDCustomer.

What is the problem? Why this happens?

Is there any solution (except back to 2003)?

Thanks in advance for your help.

Joe

This is probably another reserved name. 2007 is much pickier about using
reserved words (Code, Date, Order, etc.) as fieldnames.

Does it work if you use AS CustomerCode? Or you might try

AS [code]

--

John W. Vinson [MVP]



.

  #6  
Old February 8th, 2010, 12:40 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Querying using SQL statement

I can't say this is happening and can't test to see if this behavior is
different in 2007 versus 2003.

I would check that there is no Caption property set for the fields. Access
tends to display that as a column header (name) when you are displaying the
results of a query in datasheet view. Besides checking the fields in the
tables, check the caption property of the fields in the query if you are using
query design view.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Joe wrote:
Hi John

The name Code was just an example.

Anything I type, a regular text or even a name - Robert - for example, it
doesn't work.

I'm using a Access 2007 in Brazilian-portuguese version.

This customized version could be the problem? In positive case, is there a
solution?

Thanks in advance for your time and answer.

Joe






"John W. Vinson" escreveu na mensagem
...
On Sun, 7 Feb 2010 20:31:19 -0200, "Joe" wrote:

Hi

Using an expression as follows...

SELECT IDCustomer AS Code, Name, Address FROM Customers

...the AS clause doesn't work in Access 2007.

Running the query, the column caption remains IDCustomer.

What is the problem? Why this happens?

Is there any solution (except back to 2003)?

Thanks in advance for your help.

Joe

This is probably another reserved name. 2007 is much pickier about using
reserved words (Code, Date, Order, etc.) as fieldnames.

Does it work if you use AS CustomerCode? Or you might try

AS [code]

--

John W. Vinson [MVP]



 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.