首页 > 解决方案 > 在不会更改的临时变量中捕获表值

问题描述

所以,假设我有这样的事情:

Do While Rec.EOF = False
    'Capture the temp numbers right when you get to the new record, because the table values can change
    ODN = Rec("OpenDayNumber")
    CDN = Rec("CloseDayNumber")

    If Rec("OpenDayNumber") >= X1 and =< Y1, then
        'If the next record starts during the current one but ends after the current one...
        If Rec("CloseDayNumber") > Y1, then
            'Just set the OpenDayNumber of the following record to the CloseDayNumber of the current one
            ' so it doesn't double-count any days
            Rec.Edit
            Rec("OpenDayNumber") = Y1
            Rec.Update
        else
            'Ignore Rec (X + 1), it occurred entirely during Rec X.  Set its TotalPendDays to 0.
            Rec.Edit
            Rec("OpenDayNumber") = Rec("CloseDayNumber")
            Rec.Update
        end if
    else
        'its a legit new pend, and should be counted in its entirety
    end if  


    X1 = ODN
    Y1 = CDN    
    rec.MoveNext

Loop  

如何让 X1 和 Y1 分别捕获 ODN 和 CDN 的值?一旦表中的数据发生变化,变量的值就会发生变化。嗯,Rec("CloseDayNumber")永远不会改变,但Rec("OpenDayNumber")可以改变。在进行任何更改之前,我希望 X1 等于 ODN 的值。

标签: vbams-access

解决方案


推荐阅读