Date Field with Default Value of Now()

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
 
P

Pete D.

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.
 
J

John W. Vinson

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!
 

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