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!

Identity of Person Who Exported Table

Status
Not open for further replies.

kristi1023

Programmer
Jan 8, 2002
59
US
I am running a macro that transfers a table from a local version of the db to another version of the database located on the network. I'm wondering, is there a way of detecting the identity of the person who exported the database? Perhaps, their login id? Thank you.
 
I am not sure about the best way to do this, but you can get the id of the person logged onto the pc with the environ("username") function. Nick (Everton Rool OK!)
 
The best thing to do would be to create a small table to store the user and date of the export. Then, assuming you call the macro from a command button or the like, before the macro run, capture the loginid of the user from the system registry information and write this to the table. There are several ways to capture the user name...just search this forum or let me know and I can e-mail you the code for it. Hope this helps.

cmdButton:
Call CaptureUserIdFunction
Write UserId and Now() info to table
Call ExportMacro "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." Albert Einstein. [spin]

Robert L. Johnson III, A+, Network+, MCP
robert.l.johnson.iii@citi.com
 
Hey there. I've been waiting long time to brag about this code I came up with. Hope it is helpfull here.

This will retrieve data from the Envirment, in this case "s_login" which happens to be where our companies user ID's are stored from logging in. It then records it on a table "Use Log" as well as placing it on a form "Master List". Of course this does not address performing the action upon export but it's a start.

(side note here... I came accross another envirment where "User ID" was the string used to store the login id. if the code does not return a user name you can find the correct string to search for by displaying the strings found in a msgbox, cycling through until you find one that has your user id listed.)

On Error Resume Next
Dim EnvString, Indx, Msg, PathLen, UserID
Indx = 1
Do
EnvString = Environ(Indx)
'***msgbox EnvString 'Unconment this and
'***coment all but loop statement to find the
'***string containing your userid's.
If Left(EnvString, 8) = "s_login=" Then
PathLen = Len(Environ("s_login"))
UserID = Right(EnvString, PathLen)

Dim MyDB As Database, Mytable As Recordset, MyTable2 As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set Mytable = MyDB.OpenRecordset("Users", DB_OPEN_TABLE)
Mytable.Index = "UserID"
Mytable.Seek "=", UserID
If Not Mytable.NoMatch Then
Forms![Master List]![Security] = Mytable.Security
Forms![Master List]![UserID] = UserID

Set MyTable2 = MyDB.OpenRecordset("Use Log", DB_OPEN_TABLE)
MyTable2.Index = "PrimaryKey"
MyTable2.AddNew
MyTable2("Index #") = Forms![Login]![Index #]
MyTable2("Date") = Date
MyTable2("Time") = Time
MyTable2("Action") = "In"
Forms![Login]![UseID] = MyTable2.ID
MyTable2.Update
MyTable2.Close

End If

Exit Do
Else
Indx = Indx + 1
End If
Loop Until EnvString = ""

 
Thank you all for your recommendations! I haven't had the time to try any of them yet, but I'm sure that with your input, I'll be able to figure something out. Thanks, again [shadeshappy]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top