Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to capture time of record edit 2

Status
Not open for further replies.

tlove161

Technical User
Feb 5, 2004
42
US
I have a field in my table that is called LastEdit. The default value is =Now(). It assigns a date/time when the record is first created.

I want it to capture a new time and replace the old time whenever I edit a field in that record. Right now it does not update the date/time field when I make an edit.

What do I need to do so that I can capture the time when I make an edit to a field in a record? Thanks.
 
Are you editing directly from the table or are you using a form?


HTH
Mike

[penguin] Dooobie...Doobie......Dooo
 
I am using a form to enter the data. Thanks
 
Ok, since you are using a form you can simply add some code to the form that will set the value of that field to the current date/time after updating any field on the form.

Here is how:

1) Make sure to have a field that uses LastEdit as its control source. Make it hidden if you don't want the users to see it.

2) Add this code to the after update event of the form
Code:
Private Sub Form_AfterUpdate()

    Me.LastEdit = Now()

End Sub

Now whenever any field on the record is modified it will automatically change the LastEdit field to Now().

HTH
Mike

[penguin] Dooobie...Doobie......Dooo
 
mgolla-

I added the code and stuff to the form. But now when I do make an edit on the form, I can't navigate to the next record and when closing the form I get a warning saying Access can't save the record. Now what?
 
What happens when you try to navigate?

HTH
Mike

[penguin] Dooobie...Doobie......Dooo

Beware the penguins
 
mgolla-

I click the little arrow and nothing happens. I can navigate thru until I make an edit. Thanks
 
Hi!

Try moving it to the forms before update event in stead

Roy-Vidar
 
Try moving it to the Before Update event:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

    Me.LastEdit = Now()

End Sub

HTH
Mike

[penguin] Dooobie...Doobie......Dooo

Beware the penguins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top