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

placing current date in a field when a record is modified

Status
Not open for further replies.

ray436

Technical User
Apr 11, 2000
254
CA
Hi all, <br><br>We have a large database of Customer records that need to have the user show when the record was last &quot;worked&quot; as in the info was changed.<br><br>Is the a fairly straight-forward way to have the current date placed in a field to show when a record has been modified?<br><br>There is a field there now, but too often the user &quot;forgets&quot; to enter the current date when they work the files.<br><br>Thanxs.........
 
The simplist way would be to set the default value of the field (in table design view) to Date().&nbsp;&nbsp;<br><br>This will assign the current date value to that field when the record is created.<br><br>If you are using a form to add records and modify data, you will need to add some code to update the date field to the current date when the record is modified:<br>&nbsp;&nbsp;ModDate = Date()<br><br>I would put this code in the On Click Event of a Save Record command button or in an after update event of one of the fields sure to be modified.<br><br>Hope this helps.<br><br> <p>Larry De Laruelle<br><a href=mailto:larry1de@yahoo.com>larry1de@yahoo.com</a><br><a href= > </a><br>
 
LarryDeLaruelle is correct, but depending on your form, there may not be any one particular field guaranteed to be modified. and only updating the date when a record is modified is a little more (not alot) complex than updating when record is accessed.<br><br>i'd put the code Larry suggests <b>ModDate=Date()</b> behind the AfterUpdate property of several fields in the form, or if you want to be bulletproof, put it behind all of them (of course you could always put it in the After Update property of the form itself). it's only one line of code, and it shouldn't mess anything else up anyway.<br><br>oh yeah, change ModDate to the name of your date field. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
Use the form's Before Update event to do what you want. This event only fires if a record has been added or if the record has been changed. This also is the last event that fires before the changes are saved.<br><br>I would use the Now() function to capture both the date and time of action.<br><br>Private Sub Form_BeforeUpdate(Cancel As Integer)<br>Me!{ModDate} = Now()<br>End Sub<br><br>HTH<br>RDH <p>Ricky Hicks<br><a href=mailto: rdhicks@mindspring.com> rdhicks@mindspring.com</a><br><a href= > </a><br>
 
Hmmmmmmm....<br><br>Yes, I do believe I like this,<br><br>I used the following :<br><br>Private Sub Form_BeforeUpdate(Cancel As Integer)<br>[Last_Updated] = Now()<br>End Sub<br><br><br>I think this little &quot;scrap&quot; will be going into all the databases, some with one that also does the same thing with the user's log-in ID from the entry macro. No more figuring out who did what when....!!!<br><br><br>thank-you very much all !!!<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top