I am using the following vba code to execute an sql statement in Access 2007:
SQL = "ALTER TABLE " & strNEW & _
" ADD COLUMN ([GolfLengte] INT) DEFAULT " & _
strTableName
DoCmd.RunSQL (SQL)
Wich prints:
ALTER TABLE tbl_GL_850 ADD COLUMN ([GolfLengte] INT) DEFAULT 850
The query should update an already existing table with already existing records:
Table1
+--------------+----------+----------+
| Column1 | Column2 | Column3 |
+--------------+----------+----------+
| x | x | x |
+--------------+----------+----------+
| x | x | x |
+--------------+----------+----------+
| x | x | x |
+--------------+----------+----------+
| x | x | x |
+--------------+----------+----------+
What I would like is another column added with In every record the value that is written in the variable strTableName like so:
Table1 strTableName = 850
+--------------+----------+----------+----------+
| Column1 | Column2 | Column3 |GolfLengte|
+--------------+----------+----------+----------+
| x | x | x | 850 |
+--------------+----------+----------+----------+
| x | x | x | 850 |
+--------------+----------+----------+----------+
| x | x | x | 850 |
+--------------+----------+----------+----------+
| x | x | x | 850 |
+--------------+----------+----------+----------+
Seems to me that it is a valid SQL statement, but for some reason vba keeps telling me that there is a syntax error while highlighting
DoCmd.RunSQL (SQL)
What am I doing wrong?