Solved

Syntax error in Alter Table statement

Posted on 2016-09-26
8
48 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
  • 3
  • 3
  • 2
8 Comments
 
LVL 49

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
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 49

Expert Comment

by:Gustav Brock
ID: 41816547
You are welcome!

/gustav
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

744 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now