Date/Time load when record updated

dr223

Registered User.
Local time
Today, 04:32
Joined
Nov 15, 2007
Messages
219
Hi all,

I have a form which is also build with a subform. In the form I add the date and time when a record is changed/added to a respective table in the database. So that, when the next administrator logs in he/she can see when the form was last updated.

I used the following code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo BeforeUpdate_Err

' Set bound controls to system date and time.
DateModified = Date
TimeModified = Time()

BeforeUpdate_End:
Exit Sub

BeforeUpdate_Err:
MsgBox Err.Description, vbCritical & vbOKOnly, _
"Error Number " & Err.Number & " Occurred"
Resume BeforeUpdate_End
End Sub


This works successfully, and imports the date and time when a record has been last modified or added.

The problem I am faced with is that, whenever I change data within the subform, the date and time is not updated to reflect to the change i.e., date and time is not affected with any changes to the subform amendments. How can I rectify this?

Thank you very much indeed
 
When you open a form with the required information, the form remains "static". That is the information contained on the form and subform remain the same in your display. Changes that you actually make in the text boxes are of course displayed at once but the other fields that may be dependant on those changes will not be updated on the form unless you have specifically instructed the FORM to make those changes in the display.
This is called "refreshing" the form.
As an exercise, make a change in your date/update form on a record. Close the form then re-open it to the same record. BOTH changes should be present.
You need to enter the necessary code to tell the form that when you make a change in the date field it should refresh the form the show the change in the dependant field.
 
Hi statsman,

I did as you said, however, when I retrieved that data. The changes on the subform took effect, but the date and time was not updated even after refreshing the subform. The effect will always take place (change in date and time), when the change is done on the Form NOT subform. The change in Date /Time is only restricted to the Form (Parent) as I call it.

Thanks for your suggestion, any ideas
 

Users who are viewing this thread

Back
Top Bottom