Add date stamp to Access 2003 Form?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I add a date/time stampo top an Access form that automatically updates
on input or modify? Online Help suggests an event or macro but gives no
details of how to do it.
 
You will need to add two date/time fields to your table to hold the details
of when the record was created, and when the record was updated.

For the WhenCreated field, you can just set the Default Value property to:
=Now()

For the WhenUpdated field, you need to use the BeforeUpdate event of the
*form* to assign this value:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not Me.NewRecord Then
Me.[WhenUpdated] = Now()
End If
End Sub
 
This code is not working for me.......... any ideas as to why???

Allen Browne said:
You will need to add two date/time fields to your table to hold the details
of when the record was created, and when the record was updated.

For the WhenCreated field, you can just set the Default Value property to:
=Now()

For the WhenUpdated field, you need to use the BeforeUpdate event of the
*form* to assign this value:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not Me.NewRecord Then
Me.[WhenUpdated] = Now()
End If
End Sub

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

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

Richard G Hunt said:
How do I add a date/time stampo top an Access form that automatically
updates
on input or modify? Online Help suggests an event or macro but gives no
details of how to do it.
 
Karen said:
This code is not working for me.......... any ideas as to why???

Hi Karen,

It's kind of hard to come up with ideas when there's so little
information given.

My guess is that it's not working because of wrong field names. Allen
more than likely just 'pulled names out of the air' to give you an
example; for his suggested code to work you need to 1) have the fields
in your table and 2)use your field names in the code.

If this doesn't get you on the pathway towards finding your solution,
post back with 1) your actual control names, 2) your actual code and 3)
the text of the error message (if any) that you are getting - or - an
explanation of what you mean by 'this is not working for me'

With that information someone here will be more able to assist you.

--
Clif
Still learning Access 2003



Allen Browne said:
You will need to add two date/time fields to your table to hold the
details
of when the record was created, and when the record was updated.

For the WhenCreated field, you can just set the Default Value
property to:
=Now()

For the WhenUpdated field, you need to use the BeforeUpdate event of
the
*form* to assign this value:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not Me.NewRecord Then
Me.[WhenUpdated] = Now()
End If
End Sub

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

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

message
How do I add a date/time stampo top an Access form that
automatically
updates
on input or modify? Online Help suggests an event or macro but
gives no
details of how to do it.
 
Back
Top