Help With Auto Update for Date field

wolfegirl04

New member
Local time
Today, 14:00
Joined
Mar 19, 2004
Messages
7
Hi,

I made a very simple database to keep address for various businesses that we deal with on a regular basis. I have one form for data entry. I have a filed called "Date Updated". I would like this field to be automatically updated (with out me having to type in the days date) to the day the information for that record was added, changed or updated.

Can anyone help with a detailed step by step "How To"?

Thank You
 
If you have a button that the user presses you can add the code the the OnClick event

Code:
Datefield = FormatDateTime(Now(), vbShortDate)

or if you don't have a button you can add it to one your text boxes OnChange event.
 
The BeforeUpdate event of the FORM is the most appropriate place. That way the update will happen without any specific interaction with the user and will happen ONLY if the record has been changed. Using a button leaves the update decision up to the user who may forget or who may click the update even when nothing was actually changed. There is no reason to even show the update date on the form unless you have a need to show the present value. If you do choose to show the field, make sure that the control is disabled because you don't want someone changing the value either deliberately or by accident. Updates to this field should be totally under control of the program for auditing purposes.

The code is:
Me.LastUpdateDt = Now()

Formatting a date field turns it into a text string so there is no need to do it. You can define a specific format for this date field but it should also show time since time is a component of Now() and the value of the LastUpdateDt field will include both the date and time of the update.

Most people also store the logon id of the person making the change.
 

Users who are viewing this thread

Back
Top Bottom