Dim trv As WinForm.TreeView = e.Sender
Dim flt As String
Dim filter As String = "1=2"
For Each nd As WinForm.TreeNode In e.node.Nodes '清除子节点选中状态
nd.Checked = False
Next
If e.node.ParentNode IsNot Nothing Then '去掉父节点选中状态
e.node.ParentNode.Checked = False
End If
For Each nd As WinForm.TreeNode In trv.AllNodes
If nd.Checked Then
If flt > "" Then
flt = flt & " Or " '注意用or而不是And
End If
If nd.Level = 0 Then '注意下面的条件都要用括号括起来
flt = flt & "( 方案名称 = '" & nd.Text & "')"
filter &= " or 方案名称 = '" & nd.Text & "'"
Else
flt = flt & "( 方案名称 = '" & nd.ParentNode.Text & "' And 鱼群名称 = '" & nd.Text & "')"
filter &= " or 方案名称 = '" & nd.ParentNode.Text & "'"
End If
End If
Next
'DataTables("汇总分析_VIP回访记录").loadFilter = flt
'DataTables("汇总分析_VIP回访记录").load
Dim sql As String
sql = "Select 消费日期 As 日期, 归属门店, SUM(实销金额) As VIP销售额, COUNT(DISTINCT VIP卡号) As VIP销售笔数 FROM {VIP消费信息} where VIP电话 in (select VIP电话 from VIP回访记录 where " & filter & " ) GROUP BY 消费日期, 归属门店 "
Tables("汇总分析_到店人数统计").Fill( sql,"VIP数据",True)