We recently updated our
Terms and Conditions for TechRepublic Premium.
By clicking continue, you agree to these updated terms.
Invalid email/username and password combination supplied.
An email has been sent to you with instructions on how to reset your password.
Welcome to TechRepublic!
All fields are required. Username must be unique. Password must be a minimum of 6 characters and have any 3 of the 4 items: a number (0 through 9), a special character (such as !, $, #, %), an uppercase character (A through Z) or a lowercase (a through z) character (no spaces).
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
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.
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
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.
‘update other fields from the form then