Date and time

Y

Yasas de Silva

How do I set up an automatic date and time field in Access which updates upon
changes to the record?
 
D

Douglas J. Steele

You can't. The only way you can get that capability is to put logic into the
form's BeforeUpdate event to change the date/time field.
 
J

John Vinson

On Sun, 6 Feb 2005 17:23:02 -0800, "Yasas de Silva" <Yasas de
How do I set up an automatic date and time field in Access which updates upon
changes to the record?

You'll need to do all changes to the data using a Form. Table
datasheets have no usable events.

Given this, just add a date/time field to the table, let's call it
ChangeTimestamp, and use VBA code in the Form's BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel as Integer)
<any record validation code here>
Me!ChangeTimestamp = Now
End Sub

John W. Vinson[MVP]
 
J

John Vinson

Isn't the assumption that all changes to the data *will* be done 'using
a Form' wishful thinking? The front end shouldn't be used in place of
database constraints. How about a CHECK constraint to ensure the date
amended is always current? e.g.

That would be nice if Access supported CHECK constraints, Jamie.

Sorry, we're not using SQL/Server here. This is a different program
with different syntax. Triggers would be nice too.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top