Last Accessed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Is there a way to capture a persons pc user's login in a table in access
when it is opened.

eg User "A" opens the database, a table records that users pc user login,
then user "B" opens same database and a table records their pc user login as
the next record etc etc...

What I am trying to do is capture who last opened that database and or made
changes.

cheers
 
A switchboard is a form, so you've already got that part happening.

Take the code from http://www.mvps.org/access/api/api0008.htm and copy it
into a new module. (Make sure you don't name the module fOSUserName: modules
can't use the same name as routines within them)

Create a table (let's name it Usage for the sake of argument) that contains
at least 2 fields: UserId (a text field that's at least as long as your
longest user name) and LoginDtm (a date field)

Open your switchboard in Design mode, then add the following code to either
its Open or Load event:

Dim strSQL As String

strSQL = "INSERT INTO Usage(UserId, LoginDtm) " & _
"VALUES ('" & fOSUserName & "', " & _
Format$(Now, "\#mm\/dd\/yyyy hh\:nn\:ss\#") & ")"

CurrentDb.Execute strSQL, dbFailOnError

Each time the switchboard form is opened up, a row will be written to your
table.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



pjd said:
Thanks for the reply.

I've set the database so that a switchboard opens automatically when the
databased is opened.

How do I "have a form that opens when you open the database, and have its
Open event write the user ID to a table"

I know very little about VBA.

Thanks
 
Back
Top