View Full Version : Inputting date automatically and saving to table


Rose
08-02-2001, 01:46 AM
Can anyone tell me how to automatically generate the date that a record was updated into a field and to save that date to a table. When I do it, it always shows the current date rather than the date that the record was updated.

Thanks

Rose

KKilfoil
08-02-2001, 07:04 AM
I don't know if this is the best way, but what I do is use the AfterUpdate event for the appropriate controls of my form (I assume you would want to do this in a form since you posted to this forum) to write the current date/time to my WhenUpdated control/field.

Pat Hartman
08-02-2001, 08:04 AM
In the BeforeUpdate event of the FORM put the following:

Me.YourtableDate = Now()

Remove any defaults or other updates to this field that you might have. You should also set enabled to no and locked to yes on the property sheet if the field is also displayed on the form. This prevents the user from updating it also.

I don't recommend putting this code in an event related to a particular field as KKilfoil suggested unless you only want to track updates to a particular field. If you want the date/time to change whenever anything is changed, you need to put it where I suggested or duplicate the same code in EVERY control on the form.