Dim cnl As WinForm.ComboBox = Forms("资料查询").Controls("ComboBox1")
Dim tx1 As WinForm.TextBox = Forms("资料查询").Controls("TextBox1")
Dim tx2 As WinForm.TextBox = Forms("资料查询").Controls("TextBox2")
Dim tx3 As WinForm.TextBox = Forms("资料查询").Controls("TextBox3")
Dim t As Table = Tables("资料查询_资料查询")
Dim y As String
If tx2.text = "" And tx3.text = ""
y = "12"
ElseIf tx2.text = "" And tx3.text <> ""
msgbox("少月份啦~")
Return
Else
y = tx2.text
End If
Dim yf As String = "4,6,9,11,04,06,09,11"
Dim dd,dd1 As String
If yf.contains(tx2.text) And tx1.text IsNot Nothing And tx2.text <> "1"
dd = "30"
ElseIf Date.IsLeapYear(tx1.text) = True And (tx2.text = "" Or tx2.text = "2")
dd = "29"
ElseIf Date.IsLeapYear(tx1.text) = False And tx2.text = "2"
dd = "28"
ElseIf tx2.text = "1"
dd = "31"
Else
dd = "31"
End If
If tx3.text = ""
dd1 = "1"
Else
dd1 = tx3.text
End If
If cnl.text > "" And tx1.text > "" And tx2.text > "" And tx3.text > ""
t.Filter = (cnl.text & " = #" & tx1.text & "-" & tx2.Text & "-" & tx3.Text & "#")
Else
If cnl.text <> "" And tx1.text <> ""
If tx1.text.length < 4
msgbox("年份要4位数")
Return
End If
t.filter = " " & cnl.text & " > # " & dd1 & "/" & _
y & "/" & tx1.text & "# And " & cnl.text & " < #" & _
y & "/" & dd & "/" & tx1.text & "# "
Else
msgbox("请确认某日期或年份已经输入了")
End If
End If