查询的时候出错,请问该怎么改一下
Option ExplicitPrivate Qy As String '定义保存SQL语句的变量
Private Sub Command1_Click()
Call setSQL
Adodc1.RecordSource = Qy
If Not Option1.Value And Not Option2.Value Then
MsgBox "没有选择查询方式!"
Else
Adodc1.Refresh
Set DG.DataSource = Adodc1
End If
End Sub
Private Sub Command2_Click()
Dim Qy As String
Qy = "select *from chezhuxinxi"
Adodc1.RecordSource = Qy
If Qy <> "" Then
Option1.Value = False
Option2.Value = False
Adodc1.Refresh
End If
Set DG.DataSource = Adodc1
End Sub
Private Sub Command3_Click()
Form4.Show
End Sub
Private Sub Form_Load()
Call fresh
End Sub
Private Sub fresh()
Dim strQy As String
strQy = "select*from chezhuxinxi"
Adodc1.RecordSource = strQy
Adodc1.Refresh
Set DG.DataSource = Adodc1
DG.Refresh
Option1.Value = False
Option2.Value = False
End Sub
Private Sub Text1_change()
Option1.Value = True
Call setSQL
Adodc1.RecordSource = Qy
Adodc1.Refresh
Set DG.DataSource = Adodc1
End Sub
Private Sub Text2_Change()
Option2.Value = True
Call setSQL
Adodc1.RecordSource = Qy
Adodc1.Refresh
Set DG.DataSource = Adodc1
End Sub
Private Sub setSQL()
If Option1.Value Then
If Text1.Text <> "" Then
Qy = "select*from chezhuxinxi" & "where Left(姓名," & Len(Text1.Text) & ")='" & Text1.Text & "'"
Else
MsgBox "请输入查询的姓名!"
End If
Else
If Option2.Value Then
If Text2.Text <> "" Then
Qy = "select*from chezhuxinxi" & "where Left(车牌号码," & Len(Text2.Text) & ")='" & Text2.Text & "'"
Else
MsgBox "请输入查询的车牌号码!"
End If
End If
End If
End Sub