dim str as string
dim sql as string 
dim i as integerstr="("for i=0 to ubound(b)
str = str & cstr(b(i)) & ","
nextstr = left(str,len(str)-1) & ")"sql = "select * from table where id in " & str

解决方案 »

  1.   

    创建一个临时表tblTemp
    把 B中数据循环插入TtlTemp
    select * from A where Id in(select ID from tblTemp)
      

  2.   

    Option ExplicitPrivate Sub Command1_Click()
    Dim strSql As String
    Dim i As Integer
    Dim b(1 To 10) As IntegerstrSql = "select * from A where id in('"
    For i = 1 To 10
      strSql = strSql & Trim(Str(b(i))) & "','"
    Next i
    strSql = Left(strSql, Len(strSql) - 2) & ")"
    Debug.Print strSql
    End Sub
      

  3.   

    假设b是数组:
    strSQL="select * from A where Id in(" & join(b, ",") & ")"
    rstData.open strSQL, ...
      

  4.   

    你的意思是说:
    "select * from A where id in("& strb &")"中的STRB是必须要以逗号分了???
      

  5.   

    当然,不信你直接试下面的SQL语句:
    select * from A where id in {1,2,5}