我正在使用以下 vba 代码在 Access 2007 中执行 sql 语句:
SQL = "ALTER TABLE " & strNEW & _
" ADD COLUMN ([GolfLengte] INT) DEFAULT " & _
strTableName
DoCmd.RunSQL (SQL)
印刷品:
ALTER TABLE tbl_GL_850 ADD COLUMN ([GolfLengte] INT) DEFAULT 850
查询应该使用已经存在的记录更新已经存在的表:
Table1
+--------------+----------+----------+
| Column1 | Column2 | Column3 |
+--------------+----------+----------+
| x | x | x |
+--------------+----------+----------+
| x | x | x |
+--------------+----------+----------+
| x | x | x |
+--------------+----------+----------+
| x | x | x |
+--------------+----------+----------+
我想要的是另一列添加了In every record
写入变量中的值,strTableName
如下所示:
Table1 strTableName = 850
+--------------+----------+----------+----------+
| Column1 | Column2 | Column3 |GolfLengte|
+--------------+----------+----------+----------+
| x | x | x | 850 |
+--------------+----------+----------+----------+
| x | x | x | 850 |
+--------------+----------+----------+----------+
| x | x | x | 850 |
+--------------+----------+----------+----------+
| x | x | x | 850 |
+--------------+----------+----------+----------+
在我看来,这是一个有效的 SQL 语句,但由于某种原因,vba 一直告诉我在突出显示时出现语法错误
DoCmd.RunSQL (SQL)
我究竟做错了什么?