General discussion

Locked

Access Time Stamp

By rsploss ·
How do I date/time stamp the creation of a new record, and the updating of a record?

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Access Time Stamp

by robert_a_mocarski In reply to Access Time Stamp

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.

Collapse -

Access Time Stamp

by rsploss In reply to Access Time Stamp

I'm sorry, Robert, that I couldn't get your suggestion to work for me.

Collapse -

Access Time Stamp

by Seagull Data Services In reply to Access Time Stamp

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

Collapse -

Access Time Stamp

by rsploss In reply to Access Time Stamp

Thank you, John. Your suggestion is simple and it works. Also, I appreciate seeing the same thing done in code.

Collapse -

Access Time Stamp

by rsploss In reply to Access Time Stamp

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums