Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with using numbers as Field names in Access? 1

Status
Not open for further replies.

Perilous1

IS-IT--Management
Mar 10, 2005
171
US
I have an access database that has 10 fields label '0' thru '9'. When I set up a sql query to pull data from these fields rather than getting the field names listed correctly in the DataEnvironment it lists the 10 fields as Expr 1000 thru Expr 1009.

These are not the only fields in the Table else I'd simply do a Select *. So, I acutally have the query written as "Select 0,1,2,3,4,5,6,7,8,9 From Hannah Where (date = sDate)

If I do a Select * it reflects the fields correctly but when I individualize them I get Expr 1000-1009 and the app errors out saying it cannot find the name/ordinal.
Any help with this would be appreciated.
 
Using numbers as a field name is generally a bad idea. As you've seen it confuses Access as numbers can be used as column ordinals to work with rather than the column names and if you use them as you are, it will cause problems if you need to include the columns in a WHERE clause. Also I'm not sure the data your columns are currently returning will be correct, I'd check it.

The short term fix is to wrap your column names in [] e.g.
Code:
SELECT [1],[2],[3],[4],[5],[6],[7],[8],[9]
FROM tblNumbers;
The long term fix would be to change your columns to something more meaningful.

Hope this helps

Andy
---------------------------------
[green]' Signature removed for testing purposes.[/green]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top