|
快速勾销方法
Sub EditX()
Dim dbs As Database
Dim rst1, rst2 As DAO.Recordset
Set dbs = CurrentDb
Set rst1 = dbs.OpenRecordset("SELECT 借方, 是否勾销 FROM UF WHERE (借方<>0) ORDER BY 借方", dbOpenDynaset)
Set rst2 = dbs.OpenRecordset("SELECT 贷方, 是否勾销 FROM UF WHERE (贷方<>0) ORDER BY 贷方", dbOpenDynaset)
rst1.MoveFirst
rst2.MoveFirst
Do
Select Case (rst1!借方 - rst2!贷方)
Case Is = 0 '两边相等
rst1.Edit
rst1!是否勾销 = True '借方做勾销记号
rst1.Update
rst2.Edit
rst2!是否勾销 = True '贷方做勾销记号
rst2.Update
'两个指针都向后移动
If Not rst1.EOF Then rst1.MoveNext
If Not rst2.EOF Then rst2.MoveNext
Case Is < 0 '借方数字较小
'借方指针向后移动
If Not rst1.EOF Then rst1.MoveNext
Case Is > 0 '贷方数字较小
'贷方指针向后移动
If Not rst2.EOF Then rst2.MoveNext
End Select
Loop Until rst1.EOF Or rst2.EOF '任一记录集到达末尾则不再循环
Set rst1 = Nothing
Set rst2 = Nothing
'dbs.Close
End Sub
|
|