请教组合查询的问题
如图
If Check2.Value Then
scp = "" & Combo2.Text & " = " & Text1.Text & ""
Else
scp = "" & Combo2.Text & " like'%' "
End If
Dim scp1 As String
If Check2.Value Then
scp1 = "" & Combo3.Text & " = " & Text2.Text & ""
Else
scp1 = "" & Combo3.Text & " like'%' "
End If
SQL = "select * from " & Combo1.Text & " where " & scp & "and " & scp1
If SQL = "select * from 成品交库 where " & Combo2.Text & " = ''and " & Combo3.Text & " = ''" Then
MsgBox "请选择查询条件"
Call QingKong
Exit Sub
End If
Call main1
Set adors = adoCon.Execute(SQL)
If adors.EOF Then
'清空上一次的查询记录
Call QingKong
'给出文本框提示
MsgBox "没有符合查询条件的记录!", , "成品管理系统"
Frame3.Caption = "查询根数为:" & 0 & "根"
Else
Adodc1.RecordSource = SQL
Set DataGrid1.DataSource = Adodc1
Adodc1.Refresh
请问这段代码哪里不对,我改了很久都找不到原因 谢谢
[解决办法]
'楼主这样试试:If Check2.Value Then scp = " and " & Combo2.Text & " = " & Text1.Text & ""Else scp = ""End If Dim scp1 As StringIf Check3.Value Then scp1 = " and " & Combo3.Text & " = " & Text2.Text & ""Else scp1 = ""End If SQL = "select * from " & Combo1.Text & " where 1=1 " & scp & scp1