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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling # In Field Name

Status
Not open for further replies.

BTilson

Programmer
Jul 14, 2004
139
US
I am trying to write a bit of error proofing code in one of our databases. We receive a spreadsheet regularly from our primary customer that we import into a table and run various reports on.

One of the fields on their spreadsheet is "Purch#Doc#". Part of my error proofing is to run an SQL ALTER TABLE command on some of the table fields setting their type to text. However, when I try to run the code on the Purch#Doc# field, I get the error:

Run-time error '3292': Syntax error in field definition.

I'm sure it has to do with the pound signs in the field name, as the other fields I run the code on works perfectly.

This is the code:

Code:
DoCmd.RunSQL "ALTER TABLE tSAP ALTER COLUMN Purch#Doc# text"

Anyone have any ideas on what I can do to handle this situation?

Thanks!

Brooks Tilson
Database Development
Tilson Machine, Inc.
 
how about braakets

DoCmd.RunSQL "ALTER TABLE tSAP ALTER COLUMN [Purch#Doc#] text"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top