VBA docmd.runsql中引号不能嵌套,就是说,不能出现这样的情形“…“……”…”。可是程序要求有三个以上的引号嵌套,除了单、双引号,还有没有其他的符号能替代?或者是用其他什么办法解决这个问题?

解决方案 »

  1.   

    VB的引号使用:
    dim a as string
    a="…""""……""""…"
    msgbox a
      

  2.   

    StrSql = ""
    If Not IsNull(Me.文本3) Then
       StrSql = "[日期]>= #" & Me.文本3 & "# and "
    End If
    If Not IsNull(Me.文本5) Then
       StrSql = StrSql & "[日期]<= #" & Me.文本5 & "# and "
    End If
    If Not IsNull(Me.文本7) Then
       StrSql = "[产品名称] like '" & Me.文本7 & "' and "
    End If
    StrSql = Left(StrSql, Len(StrSql) - 5)
    DoCmd.RunSQL "update 等级说明 set 数量=0"
    StrSql1 = "等级='A' and " & StrSql
    DoCmd.RunSQL "update 等级说明 set 数量=dsum('[包重]','产量明细+包明细','" & StrSql1 & "') where 等级='A'"
    'Me.OLE未绑定0.Requery
    唉,不行啊,请问以上的程序怎么办?
      

  3.   

    如果一定要用双引号的话
    用它的ASC码,比如str=chr(Asc(")) & "123" &chr(asc("))这样应该就可以了 
    一般SQL语句都用单引号。