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

Renaming a database field programmatically 1

Status
Not open for further replies.

tmarkou

Programmer
Nov 8, 2002
4
US
The following SQL statement is causing me a headache apparently because the word, "Local", is a SQL reserved word:

strSQL = "SELECT * FROM OfficeInfo WHERE Local=True"

When I run this SQL I get the following error:

Error Type:
(0x80004005)
Unspecified error
/ccdds/ListResults.asp, line 189

I'm using a Access database with VBScript. I cannot change the name of this field in the database so I must do it programmatically somehow. Someone suggested creating a another View of this particular table and change the field name in this view. Would this be a good way to go about solving this problem? If yes then how do I create another view and change the field value? Is there a better way to go about it? Maybe I'm just missing something.



 
Try this:
Code:
strSQL = "SELECT * FROM OfficeInfo WHERE OfficeInfo.Local=True"


Hope This Help
PH.
 
I've tried this but it doesn't work. I get the same error message.
 
To access some fields named as reserved words you have to use "[]". This is valid for names with spaces.

Examples: [local],[local field]

strSQL = "SELECT * FROM OfficeInfo WHERE [Local]=True"


________
George, M
 
Thanks shaddow, that did it! I appreciate the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top