[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

How can I see who is logged into the database?

I have a contact database and have setup passwords to get into the database. Here is the coding i used for the login button:

Username.SetFocus
If Username = "username" And Password = "password" Then
MsgBox "Welcome, ???", vbInformation, "???"
DoCmd.Close
DoCmd.OpenForm "Contact Database"

Is there a way that i can see who is logged into the database? Is there a Form or Report i can create? Along those same lines, is there a way i can create a log of when my guys log into the database so i know who is in and when? Thanks!!!
0
tols12
Asked:
tols12
  • 8
  • 5
3 Solutions
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:

Environ("UserName") will give you the WIndows logged in user.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
And even better ... the defacto standard:

http://access.mvps.org/access/api/api0008.htm

mx
0
 
tols12Author Commented:
Sorry for this dumb question, so i put this in a report, form, etc? Is this for a button? How do i setup what is described at http://access.mvps.org/access/api/api0008.htm?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Well, here is an example use:

Put Function fOSUserName() in a regular VBA module

The, you can call the Function like so (example)

Dim x

x = FOSUserName()

x will then equal the WIndows User Name ...
0
 
Jeffrey CoachmanCommented:
You can use this as well, if you've got the $$$

http://www.fmsinc.com/microsoftaccess/monitor.asp
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"is there a way i can create a log of when my guys log into the database so i know who is in and when?"
That's really a separate question ... rules are one question per post ....

mx
0
 
tols12Author Commented:
boaq2000, thanks for that site. I think we will look into purchasing that software!

In the mean time, i am trying to add that code to a new module. I named the new module Log. This is what i pasted into the coding:

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If (lngX > 0) Then
        fOSUserName = Left$(strUserName, lngLen - 1)
    Else
        fOSUserName = vbNullString
    End If
End Function


What do i need to change to make it work? How do I run it?
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
". I think we will look into purchasing that software! "
But that software, which I have ... cannot be accessed via vba code.  It's mainly an end user tool.

"How do I run it?"

Possibly this:

Username.SetFocus
If fOSUserName = "username" And Password = "password" Then
MsgBox "Welcome, ???", vbInformation, "???"
DoCmd.Close
DoCmd.OpenForm "Contact Database"

Not sure where you want to use this ?
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
OR

Username.SetFocus
If Username = fOSUserName  And Password = "password" Then
MsgBox "Welcome, ???", vbInformation, "???"
DoCmd.Close
DoCmd.OpenForm "Contact Database"
0
 
tols12Author Commented:
The software would be for an end user.

I will try that VBA code in just a minute.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
I should note however, that the FMS product is an excellent application and I do use it daily to monitor 25 back end databases ....

mx
0
 
tols12Author Commented:
I've requested that this question be deleted for the following reason:

Never mind.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
What is the reason for closing this Q?
0
 
tols12Author Commented:
Its not what i am looking for.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now