以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]如何让交叉查询中固定的日期能以日期输入框时间为准进行查询  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=160240)

--  作者:xuxd76
--  发布时间:2021/1/26 0:53:00
--  [求助]如何让交叉查询中固定的日期能以日期输入框时间为准进行查询
如何让交叉查询中固定的日期能以日期输入框时间为准进行查询

在窗口中加入两个日期输入框,一个开始,一个结束。
如何让g.Filter = "[业务日期] >= #1/1/2021# And [业务日期]<= #12/31/2021#"
这段代码以日期框入框的时间为准进行查询?求指教!!!

Dim g As New GroupTableBuilder("年统计", DataTables("登记表"))
g.Filter = "[业务日期] >= #1/1/2021# And [业务日期]<= #12/31/2021#"
g.Groups.AddDef("业务员")
g.Totals.AddDef("流入金额")
g.Totals.AddDef("流出金额")
g.VerticalTotal = True
g.SubTotal = True
g.Decimals = 2
g.FromServer = True
g.Build()


Tables("业务管理_统计报表").DataSource = g.BuildDataSource()
e.Form.Controls("统计报表").Visible = True

--  作者:xuxd76
--  发布时间:2021/1/26 1:01:00
--  
Dim d1 As Date = e.Form.Controls("统计_StartDate").Value
Dim d2 As Date = e.Form.Controls("统计_EndDate").Value

Dim g As New GroupTableBuilder("年统计", DataTables("登记表"))
g.Filter = "业务日期>=#" & d1 & "# and 业务日期<=#" & d2 & "#"
g.Groups.AddDef("业务员")
g.Totals.AddDef("流入金额")
g.Totals.AddDef("流出金额")
g.VerticalTotal = True
g.SubTotal = True
g.Decimals = 2
g.FromServer = True
g.Build()


Tables("业务管理_统计报表").DataSource = g.BuildDataSource()
e.Form.Controls("统计报表").Visible = True


If d1 = Nothing Or d2 = Nothing Then
    MessageBox.Show("起始或结束日期都不能为空!","友情提醒",MessageBoxButtons.OK,MessageBoxIcon.Warning)
End If

后来摸索了下,用上述代码可以实现,同时窗口提醒没有日期时不能进行统计

--  作者:有点蓝
--  发布时间:2021/1/26 8:28:00
--  
Dim d1 As Date = e.Form.Controls("统计_StartDate").Value
Dim d2 As Date = e.Form.Controls("统计_EndDate").Value
if d1 = nothing orelse d2= nothing then
msgbox("请填写统计日期")
return
end if
Dim g As New GroupTableBuilder("年统计", DataTables("登记表"))