Solved

Syntax error in Alter Table statement

Posted on 2016-09-26
8
83 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 50

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 50

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
 

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 50

Expert Comment

by:Gustav Brock
ID: 41816547
You are welcome!

/gustav
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

733 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