[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Syntax error in Alter Table statement

Posted on 2016-09-26
8
Medium Priority
?
137 Views
Last Modified: 2016-09-26
I'm using an example of the Alter Table statement from Microsoft's Developer Network website (https://msdn.microsoft.com/en-us/library/bb177883(v=office.12).aspx), but I'm getting a syntax error.  I changed the table and column names, but other than that, it's exactly like Microsoft's example.  The table was created earlier with a make-table query.  What am I doing wrong?

Set dbs = CurrentDb
dbs.Execute "ALTER TABLE RawList" & "ADD COLUMN TimesUsed INTEGER(10);"

I browsed topics and solutions, but didn't find an answer.  TIA for any suggestions...
0
Comment
Question by:Cindy Aitken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 41816521
You miss a space:
dbs.Execute "ALTER TABLE RawList" & " " & "ADD COLUMN TimesUsed INTEGER(10);"

Open in new window

/gustav
0
 

Author Comment

by:Cindy Aitken
ID: 41816527
I copied and pasted your code into mine, still getting the syntax error. :(
0
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 41816529
Is there any specific reason you need two separate strings???

dbs.Execute "ALTER TABLE RawList ADD COLUMN TimesUsed INTEGER(10);"


ET
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 52

Accepted Solution

by:
Gustav Brock earned 2000 total points
ID: 41816531
Oops. Integer doesn't go with a size:
dbs.Execute "ALTER TABLE RawList ADD COLUMN TimesUsed INTEGER;"

Open in new window


/gustav
0
 

Author Comment

by:Cindy Aitken
ID: 41816536
Nope, no reason other than that's how Microsoft's example worked.  I tried your suggestion, still getting the syntax error.
0
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 41816537
I think the syntax is ...  

dbs.Execute "ALTER TABLE RawList ADD TimesUsed INTEGER;"


ET
0
 

Author Closing Comment

by:Cindy Aitken
ID: 41816544
Ha!  That's it!  Thank you, Gustav!
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 41816547
You are welcome!

/gustav
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question