此主题相关图片如下:查询.jpg
Dim Filter As String = "1=1"
With e.Form.Controls("开始时间")
If .Value IsNot Nothing Then
Filter = Filter & " and 日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("客户名称")
If .Value IsNot Nothing Then
Filter = Filter & " and 客户名称 = '" & .Value & "'"
End If
End With
With e.Form.Controls("结束时间")
If .Value IsNot Nothing Then
Filter = Filter & " and 日期 <= #" & .Value & "#"
End If
End With
If Filter > "" Then
Tables("应收查询").Filter = Filter.replace("客户名称", "托运单位")
Tables("已扣款查询").Filter = Filter.replace("客户名称", "欠款人")
Tables("应付查询").Filter = Filter.replace("客户名称", "承运单位")
Tables("已收款查询").Filter = Filter.replace("客户名称", "交款单位")
End If
Dim dt As DataTable = DataTables("总查询表")
dt.DataRows.Clear
Dim tbs() As String = {"应收查询", "已扣款查询", "应付查询", "已收款查询"}
Dim jes() As String = {"应收查询表", "已扣款查询表", "应付查询表", "已收款查询表"}
Dim xms() As String = {"托运单位", "欠款人", "承运单位", "交款单位"}
For i As Integer = 0 To tbs.length-1
Dim tb = tbs(i)
For Each xm As String In DataTables(tb).GetValues(xms(i), Tables(tb).Filter & " And " & xms(i) & " Is not null")
Dim fdr As DataRow = dt.Find("客户名称 = '" & xm & "'")
If fdr Is Nothing Then
fdr = dt.AddNew
fdr("客户名称") = xm
End If
If fdr.Isnull(jes(i) & "金额") Then fdr(jes(i) & "金额") = 0
Next
Next
Tables("总查询表").Sort = "客户名称"
合计金额 列 是表达式列 等于 应收+已扣款—应付—已收款 能不能每次查询的时候 在合计金额列 列名后边备注一下 出现正数是客户欠我的 出现负数是我欠客户的
例如 最后一个 陈伟明 出现负数 就在合计金额 列名后边 备注一下 欠陈伟明XXX元 出现正数 就备注 XX客户 欠我 XXX元
[此贴子已经被作者于2017/1/21 10:35:20编辑过]