Sub refreshSmz()
Dim ia, ib, ic, smz As Integer
ia = 0
ib = 0
ic = id
smz = Nz(DLookup("subovermoneyz", "subaccount", "subsaveno='" & booksubsaveno & "'"), 0)
Do Until Me.NewRecord
If ia <> 0 Then overmoney = ia + buy_in - buy_out + smz: ia = overmoney
If ia = 0 Then over_money = Nz(DSum("buy_in", "accountbook", "id<=" & id), 0) - Nz(DSum("buy_out", "accountbook", "id<=" & id), 0) + smz: ia = over_money
DoCmd.GoToRecord , , acNext
ib = ib + 1
Loop
Do Until id = ic
DoCmd.GoToRecord , , acPrevious
Loop