Setting date on upadated info

lxh

Registered User.
Local time
Today, 12:11
Joined
Feb 26, 2004
Messages
43
Does anyone know how I can update a control with the current date when the value of another control is changed?

The prblem I'm having is that he control that changes is automatically updated itself (the addition of several other fields), so the on change event doesn't seem to work. I can do it on click etc, but not automatically upon a change - does anyone have any thoughts?

Thanks
Lex
 
Re: auto-updating controls

o1110010 said:
How about.. On Lost Focus? On Update?

Nope - tried both of those (and most of the others), its starting to get frustrated
 
lxh said:
Nope - tried both of those (and most of the others), its starting to get frustrated

Hm. What is the significance to these records? If you explain in more detail, maybe we can whip up some VBA you can use.
 
AfterUpdate event does not work

If you only want to record the date when particular fields change, you'll need code in the AfterUpdate events of those CONTROLS. If you want to record the date when ANY change occurs, use the BeforeUpdate event of the FORM.

Me.LastChangeDate = Now()

The date needs to be updated when the subtotal control changes, this subtotal field has code in its control source that says
Code:
=Nz([TotalCapAssCosts],0)+Nz([TotalOtherCosts],0)
and this works well.

What seems to be happening is that because the subtotal field is not manually changed the AfterUpdate event does not work. I used the BeforeUpdate event of the form just to experiment and it worked, but it is not correct as there are too many other controls on the field. Strangely the control does not record the event, so next time the form is opened the control is blank.
 
If your form was based on a Query which was calculating the subTotal then you could use the BeforeUpdate event of the form to test for the change in value.
Assuming your subTotal control is called txtTot


Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not Me.txtTot Then
Run Your Code
End If
End Sub

I assume you want this only to happen when an existing record is changed and not when adding new records in which case it becomes

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not Me.NewRecord Then
If Not Me.txtTot Then
Run Your Code
End If
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom