Dim dt1 As Date
Dim dt2 As Date
dt1=Forms("盘后作业").Controls("startdate").value
dt2=Forms("盘后作业").Controls("enddate").value
Dim Filter ="日期 >='" & dt1 & "' And 日期 <='" & dt2 & "'" & " and 单据状态='已审核'"
Tables(e.form.Name & "_Table1").fill("selec a.单据号,a.客户编码,a.客户名称,数量 as 列表数量,辅助数量 as 明细数量,金额 as 列表金额,明细金额 from {销售单} As a where "& filter &" full join (Selec 单据号,客户编码,sum(辅助数量) As 辅助数量,sum(金额) As 明细金额 from {销售单明细} where "& filter &" group by 单据号,客户编码) As b on a.单据号 = b.单据号 where (a.数量<> b.辅助数量 Or a.金额<>b.明细金额) And a.单据状态='已审核'","wjhansdata",True)
If Tables(e.form.Name & "_Table1").Current Is Nothing
messagebox.show("列表和明细一致数据准确!","信息提示",MessageBoxButtons.ok)
e.Form.close()
End If
红字部分 去掉红字就正常