首先有个总表,如下
1、定义总表的筛选条件,函数名FilterNY5
Dim e = Args(0)
Dim N1 As Integer = e.Form.Controls("NF1").value
Dim n2 As Integer = N1 - 1
Dim n3 As Integer = N1 - 2
Dim Y1 As Integer = e.Form.Controls("YF1").value
Dim Y2 As Integer = e.Form.Controls("YF2").value
Dim FilterNY5 As String = "年份=" & n2 & " OR 年份=" & n3 & " OR (年份=" & n1 & " and 月份>=" & y1 & " and 月份<=" & y2 & ")"
Return FilterNY5
2、汇总表,函数名为”零售汇总“
Dim e = Args(0)
Dim FilterNY5 As String = Functions.Execute("FilterNY5", e)
Dim b As New SQLJoinTableBuilder("零售汇总", "核算汇总表")
b.C
b.AddCols("{核算汇总表}.*")
b.Filter = "" & FilterNY5 & " and 实销金额<>0"
b.Build()
上述查询没有问题
然后对总表进行筛选
1、筛选条件函数,函数名为”跨年时间筛选bq“
Dim e = Args(0)
Dim N1 As Integer = e.Form.Controls("NF1").value
Dim N2 As Integer = e.Form.Controls("NF2").value
Dim Y1 As Integer = e.Form.Controls("YF1").value
Dim Y2 As Integer = e.Form.Controls("YF2").value
Dim FilterKNY As String
If N2 > N1 Then
FilterKNY = "(年份=" & N1 & " and 月份 >= " & Y1 & ") or (年份=" & N2 & " and 月份 <= " & Y2 & ")"
ElseIf N2 = N1 Then
FilterKNY = "(年份=" & N1 & " and 月份 >= " & Y1 & " and 月份 <= " & Y2 & ")"
End If
Return FilterKNY
2、筛选统计下如
Dim FilterKNY As String
Functions.Execute("零售汇总", e)
Functions.Execute("跨年时间筛选bq", e)
msgbox(FilterKNY)
Tables("零售汇总").Filter = FilterKNY
MainTable = Tables("零售汇总")
首先这里的msgbox(FilterKNY)显示是空值,然后筛选结果出来了FilterKNY范围内及以前年份的数据,比如筛选2024年3-5月,会出来24年3-5月及24年之前的数据,24年5月之后的数据有限制住了。不知哪里问题
[此贴子已经被作者于2025/3/10 12:31:58编辑过]
Dim FilterNY5 As String = Functions.Execute("FilterNY5", e)