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

Date stamping each record 1

Status
Not open for further replies.

mattpearcey

Technical User
Mar 7, 2001
302
GB
Does anyone have any code that i could use that will operate a function that everytime a new record is entered it is logged for time/date/user. Then, it is also logged everytime a record is edited or updated.

does anyone have any experience with this? and could possible give me some ideas as to how to go about this? i.e. can it be done using another form/subform? or can it be done behind the scenes so that it can be brought up in simple datasheet format as a report? Thank you for your help already.

Matt Pearcey
 
Suggest you check out the events that comes with the recordset object. Suspect that you could use Record/RecordsetChangeComplete event to create some kind of log.
The transaction events of the connectionobject may also be of use for you.

Good Luck
-Mats Hulten
 
The method I've often used is to simply create a date/time stamp field, and userId field in your table, and write the appropriate date/time, user name, back to the table in your AddNew and Edit record sub routines.
 
Am i being stupid, but you mean to get the user to input their user name when they input or edit data? With the time/date automatically coming up? or is this VB code that will be obvious if i look into it? sorry - but i need to master this and im struggling so far. Thank you for your help already.

Matt Pearcey
 
The current time you get from the Now() function, as to the userid you will have to find out a way to get it yourself.
Perhaps the user enters a username when he loggs in to the application that you can store in a variable, or if you want to get the username from windows there are API calls to do this. ( I can't tell you how do do it though, but the subject has been brought up before on the forum, so if nobody will supply you with the answer in this thread, the answer is out there... :)

I'm sorry that I can't supply you with a more detailed answer.

Good Luck
-Mats
 
Thanks Mats

I will take a look. Im sure i can figure some way of doing it, but my boss woould just like the best looking method thats all, so i am aiming quite high. Thanks for your guidance and help.

Thank you for your help already.

Matt Pearcey
 
Regarding retrieving username from the system, check out this FAQ: faq222-429

-Mats
 
can i just copy this code from the FAQ in? or do i have to modify wording to fit my database?

Thank you for your help already.

Matt Pearcey
 
Put the declare function in the general-declarations part. If you are using them as a part of a form you may need to put the keyword Private in front of the declaration statement.

When you have declared the functions you can use them anywhere in the scope, just look at the code how to call them. You probably don't want to display a messagebox, but yeah, you should be able to more or less just cut n' paste the code.

Good Luck
-Mats
 
Still having problems trying to sort this out. I think i have a good idea of how to do it via the coding, but i am not very good with coding so i am having probs!

What Hackster has said, i think is the easiest way that i can understand, but i need a little more guidance. Mats - i have tried to copy in the code, but ive had no luck pulling it all together. One problem that i cannot work out at all, is why when i try and enter asimple t4xt box at the first page of the record, why bu entering Now(), it will not input the date/time. This, will not show the date/time the record was last updated.

Help? Again.!? Thank you for your help already.

Matt Pearcey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top