Foxtable(狐表)用户栏目专家坐堂 → 求助,比较复杂的日期查询,狐爸来帮忙啊!


  共有8566人关注过本帖树形打印复制链接

主题:求助,比较复杂的日期查询,狐爸来帮忙啊!

帅哥哟,离线,有人找我吗?
e-png
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1695 积分:10725 威望:0 精华:0 注册:2009/10/25 16:45:00
  发帖心情 Post By:2013/3/23 22:40:00 [显示全部帖子]

这样呢:?


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 = ""
    y = "12"
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
    dd  = "30"
ElseIf Date.IsLeapYear(tx1.text) = True
    dd = "29"
ElseIf tx2.text = "2"
    dd = "28"
Else
    dd = "31"
End If
If tx3.text = ""
    dd1 = "1"
Else
    dd1 = tx3.text
End If

Dim cs As String = cnl.text &  " Like " & "'" & tx1.text & "'"

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 <> ""
        t.filter = " " & cnl.text & " > # " & dd1 & "/" & _
        y & "/" & tx1.text & "#  And  " & cnl.text & " < #" & _
        y & "/" & dd & "/" & tx1.text & "# "
    Else
        msgbox("请确认某日期或年份已经输入了")
    End If
End If

[此贴子已经被作者于2013-3-23 23:21:34编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
e-png
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1695 积分:10725 威望:0 精华:0 注册:2009/10/25 16:45:00
  发帖心情 Post By:2013/3/24 0:22:00 [显示全部帖子]

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


 回到顶部