Date Field with Default Value of Now()

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hi,

Have a database with a form to input data, the form contains a date entry
which has a default value of Now() which means the date and time are shown.
I need to know the time at the exact time the data is saved does anyone know
how I can do this?

Thanks
 
You need to put it on the before update to record it at the time entered.
As default value the person could go to lunch and not complete until
returning from lunch so could be hour or more later.
 
Hi,

Have a database with a form to input data, the form contains a date entry
which has a default value of Now() which means the date and time are shown.
I need to know the time at the exact time the data is saved does anyone know
how I can do this?

Thanks

The DefaultValue is applied the moment that the form is dirtied (by typing
into any bound control). To record the moment when the record is actually
saved to disk, use the Form's BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel as Integer)
<put any validation code first>
Me!datefield = Now
End Sub

where datefield is the desired timestamp field. The field should probably NOT
be displayed to the user, or if it is, the Enabled property of the textbox
should be No so that the user can't backdate an entry!
 
Back
Top