Dim ssq As String
Label11.Caption = "4"
a = "(select top " & Val(Label11.Caption) * 30 & " * from 查询结果显示表) a"
b = "(select top " & (Val(Label11.Caption) - 1) * 30 & " 品名范围 from 查询结果显示表) b"
ssq = "select * from " & a & "where 品名范围 not in " & b
Data3.RecordSource = ssq
Data3.Refresh

解决方案 »

  1.   

    或者:
    a = "select top " & Val(Label11.Caption) * 30 & " * from 查询结果显示表 "
    b = "(select top " & (Val(Label11.Caption) - 1) * 30 & " 品名范围 from 查询结果显示表) b"
    ssq = a & "where 品名范围 not in " & b
      

  2.   

    a = "select top " & cstr(Val(Label11.Caption) * 30) & " * from 查询结果显示表"
    b = "select top " & cstr((Val(Label11.Caption) - 1) * 30) & " * from 查询结果显示表"
      

  3.   

    to JunLing():呵呵,是的, 还要用str来转换成字符串
      

  4.   

    还是不行,提示from语句语法错误
      

  5.   

    你在Data3.RecordSource = ssq这句上设置断点,看看ssq的值是什么,贴出来
      

  6.   

    Dim a As String
    Dim b As String
    a = "select top " & CStr(Val(Label11.Caption) * 30) & "* from 查询结果显示表 "
    b = "select top " & CStr((Val(Label11.Caption) - 1) * 30) & "* from 查询结果显示表 "
    ssq = a & " where 品名范围 not in " & bData3.RecordSource = ssq
    Data3.Refresh
    提示:select字句中包含保留字,或者参数,或者标点符号不正确,哪里?我真的是找不到呀!
      

  7.   

    如下:
    select top 60* from 查询结果显示表 where 品名范围 not in select top 
    30* from 查询结果显示表
      

  8.   

    实时错误:‘3075’
    语法错误,在查询表达式 ‘品名范围 not in select top 30 * from 查询结果显示表‘中。
      

  9.   

    a = "(select top " & str(Val(Label11.Caption)*30) & " * from 查询结果显示表 order by 品名范围) a"
    b = "(select top " & str((Val(Label11.Caption)-1)*30) & " * from 查询结果显示表 order by 品名范围)"
    ssq = "select * from " & a & "where 品名范围 not in " & b
      

  10.   

    那就
    a = "(select top " & str(Val(Label11.Caption)*30) & " * from 查询结果显示表) a"
    b = "(select top " & str((Val(Label11.Caption)-1)*30) & " * from 查询结果显示表)"
    ssq = "select * from " & a & "where 品名范围 not in " & b
      

  11.   

    又写错了,偷偷上网就是不好。哎
    a = "(select top " & str(Val(Label11.Caption)*30) & " * from 查询结果显示表) a"
    b = "(select top " & str((Val(Label11.Caption)-1)*30) & " 品名范围 from 查询结果显示表)"  ----这里要指定字段的,否则不对
    ssq = "select * from " & a & "where 品名范围 not in " & b
      

  12.   

    还是不行,提示from语句语法错误,我用的winxp+vb6.0+access