方法1:循环计算
Rs.Open "Select * from A order by [ID]",Conn,1,1
If Not Rs.EOF then
Rs.MoveFirst
ID = Rs.Fields("ID")
ID_Val = Rs.Fields("字段1")
Rs.MoveNext
Do while not Rs.EOF
Conn.Excute("Update A Set [字段2] = " & Rs.Fields("字段1")-ID_Val & " where [ID] = '" & ID & "'")
ID = Rs.Fields("ID")
ID_Val = Rs.Fields("字段1")
Rs.MoveNext
Loop
Conn.Excute("Update A Set [字段2] = [字段2] where [ID] = '" & ID & "'")
EndIf
Rs.Close
方法2,:建立临时表C
Select * into C from (Select [ID],[字段1],IIF(IsNull[字段2],[字段1],[字段2]-[字段1]) as [字段2] from (Select A.[ID],A.[字段1],B.[字段1] as [字段2] from A left join A B on B.[ID]=A.[ID]+1))
删除表A, 重命名C为A