老师好,“应收款统计"表的"来源"列只引用"应收款"表"摘要"列的销售字段
Dim ysk1 As New SQLCommand '年度统计
Dim ys1 As DataTable
ysk1.C onn ecti
Dim t9 As Table = Tables("应收款")
Dim filter4 = iif(t9.filter > "", t9.filter, "1=1")
ysk1.CommandText = "SE LECT DIS TINCT year(付款日期) as 年, 摘要,客户ID,客户 from {应收款} where " & filter4
ys1 = ysk1.ExecuteReader()
For Each dr As DataRow In ys1.datarows
filter4 = "年 = '" & dr("年") & "' and 来源 = '" & dr("摘要") & "' and 客户 = '" & dr("客户") & "'"
Dim ndr As DataRow = DataTables("应收款统计").find(filter4)
If ndr Is Nothing Then
ndr = DataTables("应收款统计").addnew
End If
ndr("年") = dr("年")
ndr("来源") = dr("摘要")
ndr("客户") = dr("客户")
Next