|
Henry D. Sy 发表于 2011-10-8 09:47
lz要求,同一个人或者不同姓名,所有的尾数不同
增加两个变量进行换算,如果一拆分的尾数都要求不同,数据量大的话,也会不成立的,不知道楼主的数据量有多少条
Private Sub Command2_Click()
Dim rst As Recordset
Dim rst1 As Recordset
Dim i As Byte
Dim j As Byte
Dim k As Integer
j = 0
k = 0
CurrentDb.Execute "delete * from newtbl"
Set rst = CurrentDb.OpenRecordset("select * from 记录表 where 贷方>0 ")
rst.MoveLast
rst.MoveFirst
Set rst1 = CurrentDb.OpenRecordset("newtbl")
With rst1
Do Until rst.EOF
For i = 1 To Int(rst!贷方 / 50000)
.AddNew
!姓名 = rst(1)
!贷方 = 49999 - j
.Update
j = j + 1
k = k + j
Next
.AddNew
!姓名 = rst(1)
!贷方 = rst(3) - 49999 * (i - 1) + IIf(rst!贷方 > 50000, k - i + 1, 0)
.Update
rst.MoveNext
k = 0
Loop
End With
rst1.Close
Set rst1 = Nothing
rst.Close
Set rst = Nothing
End Sub |
|