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

Track date record modified

Status
Not open for further replies.

jh3016

Programmer
Jun 6, 2003
148
US
I am trying to put in fields that tell me who made the last change and the date they made the change. I have a main form and a subform, so if a change is made to the main form or subform, I want that tracked. I have searched this forum and tried different approaches, but nothing seems to work. Could someone tell me how to do this easily (if it is easy)? Not that great in writing or understanding codes.

Thanks in advance.
 
Hi,

use following code in Form Dirty event:

Private Sub Form_Dirty(Cancel As Integer)
dateField = Date()
userField = strUser
End Sub


Hope this helps... :)
Hasu
(Trust on someone, someone will trust you!)
 
Hi,

You should have a date field in each table (one for the parent table, one for the subform table). Maybe call them Modified.

In the <before_update> event of both the Form AND the Subform have this:

Modifed = Now()

Do the same thing to get the user into the tables also.

If you haven't got a facility to identify the user, then try looking at the CurrentUser() function.

Regards,

Darrylle


&quot;Never argue with an idiot, he'll bring you down to his level - then beat you with experience.&quot; darrylles@totalise.co.uk
 
Thanks for the quick response. I tried Hasu's approach and the dateField part works. However, I get an error message as follows for the userfield part:

Run-time error '-2147352567 (80020009)'
Field 'tblEmployee.auditUserName' cannot be a zero-length string.

Do you know what I should do?
 
set userfield of Required is no in your table.

Hope this helps... :)
Hasu
(Trust on someone, someone will trust you!)
 
Thanks. That corrected the problem. However, the username does not appear. Do I need to do anything else?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top