Question Logging Access to a database

mcclunyboy

Registered User.
Local time
Today, 00:38
Joined
Sep 8, 2009
Messages
292
Hi,

I have this functionality in an old database created in Access 95 but converted to Access 2007. However it is complicated and I am getting quite lost - I am 90% certain there must be an easier way. I did a quick search but couldn't find a reply, I will search again now.

I want to log access to a database - at the minute just logging in and out of it - opening and closing it.

I want to get username/pc number and date and enter it into the table. I will move on from there
 
Last edited:
Hi

Not sure about using Access 2007, but I use something along the lines of this, called when the Startup form is first opened.

Code:
Public Sub LogAccess()
Dim rs As DAO.RecordSet
Set rs = CurrentDb.OpenRecordset("tbl_AccessLog")
rs.AddNew
rs![strUserID] = Environ("username")
rs![strPCID] = Environ("computername")
rs![dtDateTime] = Now
rs.Update
rs.Close
Set rs = Nothing
End Sub

It wouldn't take much to change this to show when the database was opened and when it was closed; I just remove the entry from the log when the user quits so I have an 'Active Users' list, then if I need to kick them out for any reason, I know who to contact.

Obviously you don't have to use DAO, you could use ADO instead. Give me a shout if you need any more information.

Regards

Ben
 

Users who are viewing this thread

Back
Top Bottom