Solved

Syntax error in Alter Table statement

Posted on 2016-09-26
8
64 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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
 

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

773 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