笔误,IF trim(TEXT1(i).text) <> "" then
下次发上来前检查仔细一点

解决方案 »

  1.   

    改成:
    access:
    strwhere = strwhere & Label1(i).Caption & "='*" & Text1(i).Text & "'"
    sql server:
    strwhere = strwhere & Label1(i).Caption & "='%" & Text1(i).Text & "'"
      

  2.   

    谢谢提点,可以还是出现同样的错误啊,指向"For i=0 To 8",说是无效外部过程哎?怎么回事?
      

  3.   

    这样试试
    strwhere =""
    For i = 0 To 6
    If Trim(Text1(i)) <> "" Then
    strwhere = strwhere & Label1(i).Caption & "= '%" & Text1(i).Text & "%' AND "
    End If
    Next i
    I = LEN(STRWHERE )
    IF I >5 THEN STRWHERE = MID(STRWHERE,,I-5)
    strSql = "Select * from quantity where" & "" & strwhere
      

  4.   

    老大!你Private Sub Command1_Click()事件怎么能少End Sub这个结束语句呢?正确的代码是:
    Private Sub Command1_Click()
    Dim linkFlag
    Dim i As Integer
    Dim strSql
    Dim strwhere As String
    For i = 0 To 6
    If Trim(Text1(i).Text) <> "" Then
    strwhere = strwhere & Label1(i).Caption & "" & "=" * "" & "'" & Text1(i).Text & "'"
    strSql = "Select * from quantity where" & "" & strwhere
    End If
    Next i
    End Sub
      

  5.   

    老大!你Private Sub Command1_Click()事件怎么能少End Sub这个结束语句呢?正确的代码是:
    Private Sub Command1_Click()
    Dim linkFlag
    Dim i As Integer
    Dim strSql
    Dim strwhere As String
    For i = 0 To 6
    If Trim(Text1(i).Text) <> "" Then
    strwhere = strwhere & Label1(i).Caption & "" & "=" * "" & "'" & Text1(i).Text & "'"
    strSql = "Select * from quantity where" & "" & strwhere
    End If
    Next i
    End Sub
      

  6.   

    Private command1_Click()
    Dim linkFlag, i As Integer
    Dim strSql, strwhere As String
    strwhere="" 'strwhere不是一个外部变量,无初始值,应先赋值空
    For i = 0 To 6
    IF trim(TEXT1(i).text) <> "" then
    strwhere = strwhere & Label1(i).Caption & "='*" & Text1(i).Text & "'"
     strSql = "Select * from quantity where" & "" & strwhere
    End If
    Next i