在VBA中运行总和,MS Access

时间:2018-10-02 13:08:16

标签: access-vba sum ms-access-2010

我正在尝试使用另一个字段(长度)的运行总和来更新一个字段(tblUSA.RunSum),从第一个值的tblUSA.RunSum = 0开始。到目前为止,我还没有运气。 Mo更新tblUSA正在撰写。

class GameParams {
    private int current;
    private int required;
    private int level;
    private int taps;

    // constructor, getters etc.
}

class GameState {
    private int value;
    private int cost;

    // constructor, getters etc.
}

class Game {

    private int maxLevel;                   // initialized to 2 in your case
    private List<GameState> states;         // initialized to {GameState(2,0), GameState(4,5), GameState(9,8)} in your case
    private Map<GameParams, int> cache;

    // constructor, getters etc.

    private int fork(GameParams params) {   // called with GameParams(0, 15, 0, 0)
        if (chache.contains(params))
            return cache.get(params);

        // ...
    }

}

1 个答案:

答案 0 :(得分:0)

这可能会做到:

Dim db As DAO.Database
Dim rs As DAO.Recordset

Dim lastValue As Double
Dim s As String

Set db = CurrentDb()
s = "Select * From tblUSA Order By DateS"
Set rs = db.OpenRecordset(s, dbOpenDynaset)

While Not rs.EOF
    rs.Edit
       rs!RunSum.Value = lastValue   ' Initially = 0
    rs.Update
    lastValue = lastValue + rs.Fields("Length").Value
    rs.MoveNext 
Wend
rs.Close