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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timestamp changing records

Status
Not open for further replies.

gtobey

Programmer
Aug 29, 2000
11
US
I would like to put a timestamp (Date/time) into a table column when the record is updated. Putting =Now() for the default value in table design works great to obtain the date a record was added. I've tried all sorts of stuff with forms to accomplish this, but it won't fly. Any ideas. [sig][/sig]
 
Hi!

Are you sure you don't get both date and time?

This is from the VBA-help on the Now() function;

"Returns a Variant (Date) specifying the current date and time according your computer's system date and time."

Using Now() is supposed to save both date and time to a field (timestamp), but what you see is according to how you've formatted the field (date or time).

Roy-Vidar [sig][/sig]
 
You could put a hidden field on the form that holds the current date. When ever the record is saved, store this value into your table.
[sig]<p>Terry M. Hoey<br><a href=mailto:th3856@txmail.sbc.com>th3856@txmail.sbc.com</a><br><a href= > </a><br>Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?[/sig]
 
Sorry gtobey, I will take a course in reading a bit more carefully before posting again, Roy-Vidar. [sig][/sig]
 
Putting the hidden field on the form sounded great but I'm still having difficulties. To which event should I attach the code AND what would the syntax look like. Thanks. [sig][/sig]
 
I would load the hidden field when any of the other fields on the form change. I would use the After Update event for each of the other controls (text boxes, etc), and I would probably use code like:
Code:
Me!HiddenFieldName.Value = DATE()
I could be wrong on that, so test it out. Doing it this way, if someone just looks at the record, no change should be made. But if they went into a record and changed a field, the current system date should be saved out to that record along with the changes.

Hope that helps...
[sig]<p>Terry M. Hoey<br><a href=mailto:th3856@txmail.sbc.com>th3856@txmail.sbc.com</a><br><a href= > </a><br>Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?[/sig]
 
The code to update the field needs to be connected to the Form's Before Update event. This event fires only if the record has been altered or if it is a new record.

HTH s-)
RDH [sig]<p>Ricky Hicks<br><a href=mailto: rdhicks@mindspring.com> rdhicks@mindspring.com</a><br><a href= > </a><br> [/sig]
 
I Recently tried to do this as well and found the same thing, the date and time according to the help file will be put into your records but only if you have it formatted to general. I found that this still didn't work so I put two fields on my form and made their default values Date() and Time() respectively, you can then concatenate them into one field if you prefer. The other thing I found was that just using Date() would return the time as 12:00 all the time.

Help at all.

Umbane
m5gaut@mweb.co.za
[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top