Dim Filter As String = "1=1"
With e.Form.Controls("da")
If .Value IsNot Nothing Then
Filter = Filter & " and 日期 <= #" & .Value & "#"
End If
End With
Tables("进销存").Filter = Filter
Dim dtb As New DataTableBuilder("库存")
dtb.AddDef("货号", Gettype(String), 20)
dtb.AddDef("库存_数量", Gettype(Integer))
dtb.AddDef("库存_金额", Gettype(Double))
dtb.Build()
For Each nm As String In DataTables("进销存").GetValues("货号")
Dim dr As DataRow = DataTables("库存").AddNew()
dr("货号") = nm
dr("库存_数量") = DataTables("进销存").Compute("Sum(期末库存_数量)","[货号] = '" & dr("货号") & "' and " & Filter)
dr("库存_金额") = DataTables("进销存").Compute("Sum(期末库存_金额)","[货号] = '" & dr("货号") & "' and " & Filter)
Next
MainTable= Tables("库存")