还是那三个text,一个完全匹配,两个模糊匹配,从两个表中查,帮忙再看看吧。 两个表筛出来,结果总是一行。每个text筛出至少一条数据的话,按说应该至少三行才对。但结果总是后面的覆盖前面的,最后显示一条数据。
Dim Filter1 As String Dim Filter2 As String Dim Filter3 As String Dim Filter As String Dim txt1 As String = e.Form.Controls("TextBox7").Text Dim txt2 As String = e.Form.Controls("TextBox8").Text Dim txt3 As String = e.Form.Controls("TextBox9").Text
txt1 = "'" & txt1 & "'" Filter1 = "编号 = " & txt1
txt2 = "'%" & txt2 & "%'" txt3 = "'%" & txt3 & "%'" Filter2 = "公司名称 Like " & txt2 Filter3 = "产品名称 Like " & txt3
If txt1 <> "''" And txt2 <>"'%%'" And txt3 <>"'%%'" Then filter = filter1 & " or " & filter2 & " or " & filter3 End If
If txt1 = "''" And txt2 <>"'%%'" And txt3 <>"'%%'" Then filter = filter2 & " or " & filter3
End If
If txt1 = "''" And txt2 ="'%%'" And txt3 <>"'%%'" Then filter = filter3
End If
If txt1 <> "''" And txt2 ="'%%'" And txt3 <>"'%%'" Then filter = filter1 & " or " & filter3
End If
If txt1 <> "''" And txt2 ="'%%'" And txt3 ="'%%'" Then filter = filter1
End If
If txt1 = "''" And txt2 <>"'%%'" And txt3 ="'%%'" Then filter = filter2
End If
If txt1 = "''" And txt2 ="'%%'" And txt3 ="'%%'" Then messagebox.show("请填写要搜索的内容","提示")
End If
If txt1 <> "''" And txt2 <>"'%%'" And txt3 ="'%%'" Then filter = filter1 & " or " & filter2
End If
Dim dr1 As DataRow With DataTables("ChemSign1") .LoadFilter = Filter .Load dr1 = .Find(Filter)
End With
Dim dr2 As DataRow With DataTables("ChemSign2") .LoadFilter = Filter .Load dr2 = .Find(Filter)
End With
|