我在表单中有一个Access宏,我只想在空白记录上运行。如何检查记录是否已保存。 Me.dirty属性对我不起作用,因为它检查是否已更改或修改已保存的记录。
Private Sub FIND_MEMBER_AfterUpdate()
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 & "'")
End Sub
我可能有一个解决方案:
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
答案 0 :(得分:0)
听起来你正在寻找的属性是表单的.NewRecord属性,在保存新记录之前一直是真的。