Auto Date/Time

dr223

Registered User.
Local time
Today, 10:40
Joined
Nov 15, 2007
Messages
219
Hi,

I want to automatically update date and time when a record is changed or created. I have a form which is also built with a subform. The code am using is shown below: In the Before Event of the Form I have the following code;

If Me.NewRecord Then
If MsgBox("Data will be saved, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
Cancel = True
End If
Else
If MsgBox("Data will be modified, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
Cancel = True
Else

Me.txtLastUpdated = Now() '<<< Use NOW to get the date and time

End If
End If




This works perfectly and updates the Date and time when a field in the form is updated. My problem is when I update any field in the subform the date and time is not updated. I tried to put the code in the before event, but it generates an error.

Any help will be appreciated
 
Hello:

You need to put a statement telling it to update the field on the subform you wish. As of right now, you have a statement that updates the primary form only.

Regards
Mark
 
Hi Mark,

I am new with access do u have an idea what the code will be like.. Really appreciate your help!!!

Regards
 

Users who are viewing this thread

Back
Top Bottom