Office中国论坛/Access中国论坛

标题: 为什么提示第一行:')'附近有语法错误 [打印本页]

作者: clmkjszx123    时间: 2006-12-20 16:57
标题: 为什么提示第一行:')'附近有语法错误
Dim strWhere As String  '定义条件字符串
   
    strWhere = "" '设定初始值-空字符串
   
   
    If Not IsNull(Me.Z2) Then
      
        strWhere = strWhere & "([z2] like '" & Me.Z2 & "') AND "
    End If
   
   
    If Not IsNull(Me.Z4) Then
      
        strWhere = strWhere & "([z4] like '" & Me.Z4 & "') AND "
    End If

   
    If Not IsNull(Me.Z5) Then
      
        strWhere = strWhere & "([z5] like '" & Me.Z5 & "') AND "
    End If


If Len(strWhere) > 0 Then
      
        strWhere = Left(strWhere, Len(strWhere) - 5)
    End If
   
    Debug.Print strWhere
   
   
CurrentProject.Connection.Execute ("update sum1 set t1=(select count(z5) from sdmxb where strwhere)")




作者: zhangxiyou    时间: 2006-12-30 23:32
灌:最后一句中,strwhere是条件串?还是字段?如果是字段,请保证在表“sdmxb”中。。。
作者: ADAM    时间: 2007-1-5 23:31


當然出錯

應該這樣寫

CurrentProject.Connection.Execute ("update sum1 set t1=(select count(z5) from sdmxb where " & strwhere & ")")




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