谢谢提点,可以还是出现同样的错误啊,指向"For i=0 To 8",说是无效外部过程哎?怎么回事?
这样试试 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
老大!你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
老大!你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
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
access:
strwhere = strwhere & Label1(i).Caption & "='*" & Text1(i).Text & "'"
sql server:
strwhere = strwhere & Label1(i).Caption & "='%" & Text1(i).Text & "'"
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
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
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
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