如何在查询中忽略空文本框的内容
Private Sub cmdfind_Click()
Dim sql As String
sql = "select * from articlebook where aid=" & Val(Text1.Text) & " and Title ='" & Trim(Text2.Text) & "'and author = '" & Trim(Text3) & "' and atype='" & Trim(Text4.Text) & "' and afrom='" & Trim(Text5.Text) & "'"
rs.Open sql, str
If rs.EOF = True Then
MsgBox "对不起此处没有你要找的信息", vbOKOnly, "警告"
End If
rs.Close
End Sub
每个文本框中的内容为查询条件(每个文本框对应数据库中的一个字段)组合查询
问题:当有文本框为空时查询结果为空,怎样才能忽略空的文本框,程序该怎样写