TimeStamp Field in Access Table?

  • Thread starter Thread starter Dan Johnson
  • Start date Start date
D

Dan Johnson

Is it possible to add a date/time field to an Access table that is
automatically updated every time the record is changed? Sorry if this has
been asked before...I tried looking through recent topics and didn't see it.

Dan
 
You cannot do this at the table-level in Access.

If your data is edited in a form, you can use the BeforeUpdate event of the
form to assign the value of Now() to the date/time field, e.g.:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[NameOfYourTextBoxHere] = Now()
End Sub
 
Thanks Allen.

Do you know off the top of your head if I can use an ADODB.Recordset event
in VB6 to make sure a TimeStamp field is always updated when a record is
changed?

Dan

Allen Browne said:
You cannot do this at the table-level in Access.

If your data is edited in a form, you can use the BeforeUpdate event of the
form to assign the value of Now() to the date/time field, e.g.:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[NameOfYourTextBoxHere] = Now()
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dan Johnson said:
Is it possible to add a date/time field to an Access table that is
automatically updated every time the record is changed? Sorry if this has
been asked before...I tried looking through recent topics and didn't see
it.
 
If you are updating via a recordset, then you can code it so that the
particular date/time field is updated as well.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dan Johnson said:
Thanks Allen.

Do you know off the top of your head if I can use an ADODB.Recordset event
in VB6 to make sure a TimeStamp field is always updated when a record is
changed?

Dan

Allen Browne said:
You cannot do this at the table-level in Access.

If your data is edited in a form, you can use the BeforeUpdate event of the
form to assign the value of Now() to the date/time field, e.g.:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[NameOfYourTextBoxHere] = Now()
End Sub

Dan Johnson said:
Is it possible to add a date/time field to an Access table that is
automatically updated every time the record is changed? Sorry if this has
been asked before...I tried looking through recent topics and didn't
see
it.
 
Back
Top