vsteinly

vsteinly

Registered User.
Local time
Yesterday, 19:44
Joined
Dec 6, 2013
Messages
20
I have created two tables in which I want to track who and what time data is entered and then again if the table is modified. I found this code which I added to BeforeUpdate:

Private Sub Form_BeforeUpdate(Cancel As Integer)
ModBy = Environ("username")
ModDate = Now()
End Sub
Private Sub Form_Current()
If Me.NewRecord Then
CreateBy = Environ("username")
End If
End Sub
So I went in and tested the code and it did put in the date but now my username. Do I need to created a table of users and then make the database password driven. Also this is a split database.

Just to let you know I know enough to be dangerous!
 
Please tell us about
"I have created two tables"
It seems you would need a CreateDate = Now() also, if you want to know when the record was created.
 
I see what you are talking about but for some crazy reason that field I updated. So what do you think I need to do for the username?
 
I see what you are talking about but for some crazy reason that field I updated. So what do you think I need to do for the username?

Do you definitely have a username available? So if you just wrote some code that said
Msgbox Environ("Username")
Does anything come up?

As far as I know, Environ("Username") returns the windows user name, so should do what you want (won't work on Macs!).
 
I'm not getting anything to show up in the createdby field. I did notice two new fields that showed up on my form and wondered it there was something that I could with them. One is called System Name: and another called System Id Number:
 
What do you mean they showed up on your form?

Were I go guess I would say they are something to do with name you give the computer on a network, and perhaps a related ID. So could potentially use it to determine what PC a change was made from, but not by which user on that PC.
 
Here is a screen print of the input form in design mode.

I'm going to get with my IT guys today to see how they would grab the username.
 

Attachments

  • MFS.jpg
    MFS.jpg
    62.1 KB · Views: 79

Users who are viewing this thread

Back
Top Bottom