Check for changed records

accessNator

Registered User.
Local time
Today, 17:07
Joined
Oct 17, 2008
Messages
132
I have an form which is bound to a query recordset.

If a user changes any items in the form, how do I check if any of the items have been changed before it is saved when they click on a SAVE button?

I assume I would use a BEFOREUPDATE event, but what is the syntax to loop through the controls and check if anything has been changed?

How do I do a comparison between the original and change value?

Thanks for your assistance.
 
Check out the forms "On Dirty" event in Access Help. This may be something you are looking for.

-dK
 
Check out the forms "On Dirty" event in Access Help. This may be something you are looking for.

-dK

Interesting. So on the OnDirty event, can you give me a quick example of comparison on a control? What would be the syntax in the OnDirty event?
 
Actually, you can just check the form's Dirty property in the click event of your button:

If Me.Dirty Then ....

and do whatever there.
 
Also, you may want to use Controls collection to loop through all controls and compare their Value against OldValue.

But why not use audit trail?
 
For the form, if any control's data on the form is different .. for the control, only if that specific control data is different.

For the form ... perhaps placed on a button or some other procedure:

Code:
If Me.Dirty = True Then
    MsgBox "Form is dirty"
Else
    MsgBox "Form is not dirty"
End If

For a control ...

Code:
If Me.txtControlName.Dirty = True Then
    MsgBox "Control is dirty"
Else
    MsgBox "Control is not dirty"
End If

-dK
 
Also, you may want to use Controls collection to loop through all controls and compare their Value against OldValue.

But why not use audit trail?

I will have to research in the future on the use of Audit Trail. Still learning. Thanks. I also plan on looping when needed.
 
For the form, if any control's data on the form is different .. for the control, only if that specific control data is different.

For the form ... perhaps placed on a button or some other procedure:

Code:
If Me.Dirty = True Then
    MsgBox "Form is dirty"
Else
    MsgBox "Form is not dirty"
End If
For a control ...

Code:
If Me.txtControlName.Dirty = True Then
    MsgBox "Control is dirty"
Else
    MsgBox "Control is not dirty"
End If
-dK


Thanks for the quick and "DIRTY" rundown. I know, probably an old pun. Awesome.

BTW, you all are quick. I love this forum.
 
As a note ... I don't recall which one but there was a conversation in helping a user in the last few weeks where code was demonstrated on how to loop through the controls and on how to compare the current value and the old value.

-dK
 

Users who are viewing this thread

Back
Top Bottom