two date time fields

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

JSand42737

"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
 
G

Guest

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

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