高人帮我看一个菜鸟VB问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 12:08:31
Private Sub Command1_Click()
Adodc1.CommandType = adCmdText

If ttb.Text = "" And ttx.Text = "" And ttr.Text = "" Then
MsgBox "请输入查询信息!"
End If

If ttb.Text <> "" Then
sql1 = ttb.Text
sqlstr1 = "select * from 读者列表 "
sqlstr2 = "where" + 读者编号 + "=" + "'" + sql1 + "'"
sqlstr = sqlstr1 + sqlstr2
Adodc1.RecordSource = sqlstr
Adodc1.Refresh
End If

End Sub

为什么要提示错误啊? 要怎么改啊?

你这里有个问题,
If ttb.Text = "" And ttx.Text = "" And ttr.Text = "" Then
MsgBox "请输入查询信息!"
End If
你用and,所以意思是说只有3个textbox都没有字的时候才会出现msgbox.所以你应该用or