开发者

check if record saved in access sub macro

开发者 https://www.devze.com 2023-03-23 17:41 出处:网络
I have an Access macro in a form that I only want to run on a blank record. How do I check to see if a record has been saved.The Me.dirty property doesn\'t work for me because it checks to see if a sa

I have an Access macro in a form that I only want to run on a blank record. How do I check to see if a record has been saved. The Me.dirty property doesn't work for me because it checks to see if a saved record have been altered or modified.

Private Sub FIND_MEMBER_AfterUpdate()
    Me.FIRST_NAME = DLookup("[FIRST_NAME]", "CM_ROSTER", "[S开发者_运维知识库OC_SEC_NUM] = '" & Me.SOC_SEC_NUM & "'")
    Me.MID_INIT = DLookup("[MID_INIT]", "CM_ROSTER", "[SOC_SEC_NUM] = '" & Me.SOC_SEC_NUM & "'")
    Me.LAST_NAME = DLookup("[LAST_NAME]", "CM_ROSTER", "[SOC_SEC_NUM] = '" & Me.SOC_SEC_NUM & "'")
End Sub

I may have a solution:

Private Sub FIND_MEMBER_AfterUpdate()

If Me.NewRecord = True Then


Me.FIRST_NAME = DLookup("[FIRST_NAME]", "CM_ROSTER", "[SOC_SEC_NUM] = '" & Me.SOC_SEC_NUM & "'")
Me.MID_INIT = DLookup("[MID_INIT]", "CM_ROSTER", "[SOC_SEC_NUM] = '" & Me.SOC_SEC_NUM & "'")
Me.LAST_NAME = DLookup("[LAST_NAME]", "CM_ROSTER", "[SOC_SEC_NUM] = '" & Me.SOC_SEC_NUM & "'")



Else

GoTo exit_sub

End If

exit_sub:

End Sub


It sounds like the property you are looking for is the form's .NewRecord property, which is true until a new record is saved.

0

精彩评论

暂无评论...
验证码 换一张
取 消