Office中国论坛/Access中国论坛

标题: 救助:SQL查询出错 [打印本页]

作者: yaozi    时间: 2009-7-30 11:21
标题: 救助:SQL查询出错
SQL = "SELECT 组别.组别" & _
"FROM 组别" & _
"WHERE 组别.编号 = 1"
DoCmd.RunSQL SQL

此语句在查询里面可用,可在VBA里提示“语法错误(操作符丢失)”
作者: rjacky    时间: 2009-7-30 11:48
注意关键字前后的空格
作者: IDEA    时间: 2009-7-30 11:53
不要分段,连成一行呢?
作者: rower    时间: 2009-11-24 20:01
楼主的问题解决了吗?
作者: holywinds    时间: 2009-11-24 23:56
句尾   ;

?
作者: 方漠    时间: 2009-11-25 10:35
RUNSQL 的用法有误, 具体请参见SQL的几种操作. SELECT是一个选择性的抽取数据操作,本身对数据不会有改动.RUNSQL不支持此类. 如果需要,可以定义一个QUERYDEF,修改其SQL就行.

RunSQL Method
See AlsoApplies ToExampleSpecificsThe RunSQL method carries out the RunSQL action in Visual Basic.

expression.RunSQL(SQLStatement, UseTransaction)
expression    Required. An expression that returns one of the objects in the Applies To list.

SQLStatement   Required Variant. A string expression that's a valid SQL statement for an action query or a data-definition query. It uses an INSERT INTO, DELETE, SELECT...INTO, UPDATE, CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, or DROP INDEX statement. Include an IN clause if you want to access another database.

UseTransaction   Optional Variant. Use True (–1) to include this query in a transaction. Use False (0) if you don't want to use a transaction. If you leave this argument blank, the default (True) is assumed.
作者: wanshan    时间: 2009-11-25 10:54
选择查询不能用在vba中




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3