最后的三重检索语句如下:
Dim d1, d2 As Date
d1 = Date_quest_buy_buybl_start.Value.Date
d2 = Date_quest_buy_buybl_end.Value.Date
Dim sup, key As String
If Check_quest_buybl_supplyer.Checked = True Then
sup = ""
Else
sup = ComboBox_quest_buy_buybl_supplyer.Text
End If
' 这里增加了一个CHECKBOX控件,以判断第二个检索是否起作用。
key = tex_quest_buybl_key.Text
OleDbConnection2.Open()
OleDb_quest_taobao_buybl.SelectCommand.CommandText = "select * from (select * from (select * from buy_bl where buy_date between #" + d1 + "# and #" + d2 + "#) where [supplyer] like '%" + sup + "%') where [blno] like '%" + key + "%'and [blno] not like '%rebu%'and [blno] not like '%monkey%' and [blno] not like '%aibei%'"
‘这里字符串检索全部用了like运算符而没有用=运算符是因为用like “% 变量名%”时,当变量为空时会选择全部字符串。另外要注意红色的部分,这里用了not 来排除一些特定的字段。
OleDb_quest_taobao_buybl.Fill(DataSet_quest_taobao_buybl1)
OleDbConnection2.Close()