哪位高人知道我的vb程序错在哪里啊?

来源:百度知道 编辑:UC知道 时间:2024/05/21 22:43:22
Private Sub Command1_Click()
a = "" & Combo1.Text & " = '" & Trim(Text1.Text) & "'"
b = "" & Combo2.Text & " = '" & Trim(Text2.Text) & "'"
If Option1.Value = True Then
Adodc1.RecordSource = "select * from 班级表 where" & a & "and" & b
ElseIf Option2.Value = True Then
Adodc1.RecordSource = "select * from 班级表 where" & b & "or" & b
Else:
Adodc1.RecordSource = "select * from 班级表 where" & a
End If
Adodc1.Refresh
DataGrid1.Refresh
End Sub

一楼都说了,晚了一步

要注意空格,and和or的前后均需要空格。
是aꪪorꪪbꪪ而不是bꪪorꪪb吧?

PrivateꪪSubꪪCommand1_Click()ꪪ
ꪪꪪaꪪ=ꪪCombo1.Textꪪ&ꪪ"ꪪ=ꪪ'"ꪪ&ꪪTrim(Text1.Text)ꪪ&ꪪ"'"ꪪ
ꪪꪪbꪪ=ꪪCombo2.Textꪪ&ꪪ"ꪪ=ꪪ'"ꪪ&ꪪTrim(Text2.Text)ꪪ&ꪪ"'"ꪪ
ꪪꪪIfꪪOption1.Valueꪪ=ꪪTrueꪪThenꪪ
ꪪꪪꪪꪪAdodc1.RecordSourceꪪ=ꪪ"selectꪪ*ꪪfromꪪ班级表ꪪwhereꪪꪪ"ꪪ&ꪪaꪪ&ꪪ"ꪪꪪandꪪꪪ"ꪪ&ꪪbꪪ
ꪪꪪElseIfꪪOption2.Valueꪪ=ꪪTrueꪪThenꪪ
ꪪꪪꪪꪪAdodc1.R