5 replies
add a field to the table with a date/time data type. Create a form to control adds/edits of the record. Add the timestamp field that you added to the table. It can be visible or hidden. On the properties of the form, add VBA code to the before update event.
The code is
Dim MyDate
MyDate = Now
time = MyDate
In that code, the field name from the table is called "time". Edit to match your field name.
Make sure you don't add the code to the after update event. That will cause Access to save the record, change the timestamp field, and then update the record again because it detected the change. An odd loop, but it does happen.
by rsploss
There are a couple of ways to do this but you need to create a date/time field in your table. Call it DateCreated:
Using a form -
create a hidden text box on the form (call it txtDateCreated) and link it to the DateCreated field.
In the event that saves the record, add the line
me.txtDateCreated=now
This will add the date and time in the appropriate place
Using Code -
where rs is the recordset you're saving to, add this code.
with rs
.addnew
'update other fields from the form then
!DateCreated=Now
.update
end with
Hope this helps
John
by rsploss
by rsploss
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending