我的宏有两个标准。
On Current
有效,但也可以在表格打开时运行。 After Update
仅在字段更改时运行。是否有符合我标准的活动?
答案 0 :(得分:2)
您可以使用静态变量:
Private Sub Form_Current()
Static Opened As Boolean
If Opened = False
' Form opens.
Opened = True
Else
' Do stuff.
End If
End Sub
操纵上一条记录:
Private Sub Form_Current()
Static Opened As Boolean
Static LastId As Long
If Opened = False
' Form opens.
Opened = True
ElseIf LastId <> 0 Then
' Do stuff using LastId as the Id.
End If
' Save current Id.
LastId = Nz(Me!Id.Value, 0)
End Sub