此主题相关图片如下:搜狗截图20200409130958.png

此主题相关图片如下:搜狗截图20200409130436.png

我要从租金库中找出每户没有交费的日期,采用的是遍历的办法,效率非常低,这只是整个表中的一户,现在整个表有2万户,每户每年有10多条记录,有10多年的记录,不用遍历的方法,用sql语句,能不能高效的找出来?Dim dr1,dr2 As Row
Dim N As Integer
Tables("租金库").Sort="交费截止日期"
For N=0 To Tables("租金库").Rows.Count-2
dr1 = Tables("租金库").Rows(N)
dr2 = Tables("租金库").Rows(N+1)
If dr2("交费起始日期")>dr1("交费截止日期") And dr2("交费起始日期").adddays(-1)<>dr1("交费截止日期") Then
Tables("欠费表").AddNew
Tables("欠费表").Current("房屋代码")= dr1("房屋代码")
Tables("欠费表").Current("欠费起始日期")= dr1("交费截止日期").adddays(1)
Tables("欠费表").Current("欠费截止日期")= dr2("交费起始日期").adddays(-1)
End If
Next
[此贴子已经被作者于2020/4/9 13:10:30编辑过]