two date time fields

  • Thread starter Thread starter eb1mom
  • Start date Start date
E

eb1mom

I am trying to create a record with two date fields.
One button on click would be the time the record was
created. Second button on click would be the time record
was saved. Both "time stamps" would be displayed on
record. Very new to access. Thanks in advance for your
help.
 
"eb1mom" said:
I am trying to create a record with two date fields.
One button on click would be the time the record was
created. Second button on click would be the time record
was saved. Both "time stamps" would be displayed on
record. Very new to access. Thanks in advance for your
help.

This can be done using a Form, rather than directly in the table.

Firstly, add the two date/time fields to the table, and then call them EditDate
and AddDate.

Next, open the form that is based on the table in design view. Select View|Code
from the Menubar, which will take you to the code module for that form.

In the displayed module, copy and paste the code below:

Private Sub Form_BeforeInsert(Cancel As Integer)
Me!AddDate = Now
Me!EditDate = Me!AddDate
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!EditDate = Now
End Sub
 
-----Original Message-----
This can be done using a Form, rather than directly in the table.

Firstly, add the two date/time fields to the table, and then call them EditDate
and AddDate.

Next, open the form that is based on the table in design view. Select View|Code
from the Menubar, which will take you to the code module for that form.

In the displayed module, copy and paste the code below:

Private Sub Form_BeforeInsert(Cancel As Integer)
Me!AddDate = Now
Me!EditDate = Me!AddDate
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!EditDate = Now
End Sub


--

Jon

www.applecore99.com - Access Tips and Tricks

.
Thank-you for your help. Your solution works great.
 
Back
Top