Db.Execute "delete from B " & _ 
          " where KH='" & fg.TextMatrix(i, 2) & "' " & _ 
          "  and dttime between (select min(dttime1) from A where KH='" & fg.TextMatrix(i, 2) & "' and dttime2 = '" & fg.TextMatrix(i, 1) & "') " & _ 
          "                  and (select max(dttime2) from A where KH='" & fg.TextMatrix(i, 2) & "' and dttime2 = '" & fg.TextMatrix(i, 1) & "') " 我想  " where KH='" & fg.TextMatrix(i, 2) & "' " & _ 在这句的KH=后面加个-号
让他变成" where KH=-'" & fg.TextMatrix(i, 2) & "' " & _ 这样子
不过这个在ACCESS数据库上能用,在SQL上确不行。 
要如何才能加上那个-号。

解决方案 »

  1.   

    " where KH='-" & fg.TextMatrix(i, 2) & "' "
      

  2.   

    这样子好像没有效果了。 
    我是想这样子的
    本来在A表选中的记录
    比如为-123456
    然后B表的记录只为123456
    然后这样子在前面加个-号会让B表的123456 认为-123456
    在ACCESS上" where KH=-'" & fg.TextMatrix(i, 2) & "' " & _ 这样子是可以的
    在SQL就会出现
    实时错误'-2147217900 (80040e14)
    对数据类型而言运算符无效。运算符为minus,类型为varchar。
      

  3.   

    不用字符串,直接数值格式
    " where KH=-" & fg.TextMatrix(i, 2) & " "