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.
精彩评论