How do I create a field in teh table that will automatically insert the time the record was made, and how do I create a field that automtaically updates when the record was modified?
Field name = DateCreated DateTime
Default Value = Now()
That's all for that one. It will work whether data is entered through a form or directly into the table.
Last modified will only work if data is entered via a form.
On the table you need:
Field name = DateModified DateTime
In the Form BeforeUpdate event procedure :
me.DateModified = Now()
In table design view for the table, define a field (DateCreated for example) with type Date and set its default value to "= Now()". That will place a the current datetime on each new record at the time it is created.
For the update of a record, you will need to explicitly set a "DateUpdated" field's value every time you do an update.
In SQL that would be
[blue][tt]
UPDATE tbl SET DateUpdated = Now(), ...
[/tt][/blue]
In Code
[blue][tt]
Dim rs As Recordset
' Open the recordset
rs![DateUpdated] = Now()
... Other Code ...
[/tt][/blue]
If you are updating via bound controls then you will need to trap the "BeforeUpdate" event and set the value there.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.