Environ("Username") should always return the Windows login ID, not Admin.
No. Because I was going through Citrix it would always bring me back "admin" but I guess it would work for this purpose, but I needed a network login.
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Friday, January 08, 2016 9:07 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Count Number of User that have backend open
Couldn't you use Environ("Username") rather than that API?
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: 08 January 2016 14:49
To: 'MS_Access_Professionals@yahoogroups.com'
Subject: RE: [MS_AccessPros] Count Number of User that have backend open
I run a script upon opening and closing the form that inserts their login name and timestamps.
It uses an API.
Option Compare Database
Option Explicit
Private Declare Function GetUserName _
Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long
Private Const MAXLEN = 255
Function GetLoginName() As String
Dim strUserName As String
Dim lngSize As Long
Dim lngReturn As Long
lngSize = 256
strUserName = Space(MAXLEN) & Chr(0)
If GetUserName(strUserName, lngSize) <> 0 Then
GetLoginName = Left(strUserName, lngSize - 1)
Else
GetLoginName = ""
End If
End Function
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
Dim strUser As String
Dim datUser As Date
strUser = GetLoginName
datUser = Now()
CurrentDb.Execute "INSERT INTO tblLoggedIn (UserLoggedIn, TimeLoggedIn) " & _
"VALUES('" & strUser & "', #" & datUser & "#)"
CurrentDb.Execute "INSERT INTO LogStats (UserLoggedIn, TimeLoggedIn, WhichDatabase) " & _
"VALUES('" & strUser & "', #" & datUser & "#, 'Inspections')"
DoCmd.OpenForm "CheckForceOut", , , , , acHidden
End Sub
Private Sub Form_Close()
Dim strUser As String
Dim datUser As Date
strUser = GetLoginName
datUser = Now()
CurrentDb.Execute "DELETE FROM tblLoggedIn WHERE UserLoggedIn = '" & strUser & "'"
CurrentDb.Execute "UPDATE LogStats SET TimeLoggedOut = #" & Now() & "#" & _
" WHERE UserLoggedIn='" & strUser & "' AND WhichDatabase = 'Inspections' AND TimeLoggedOut Is Null;"
End Sub
Then you can have a control panel type database where you can have links to those tblLoggedIn files to see who is in.
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Thursday, January 07, 2016 8:19 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Count Number of User that have backend open
I have a split database : shared backend on a network and every user has their own front end.
Is there a way to count the number of users that currently have the backend open?
I am using Access 2003.
Thanks for your help
Sarah
This email (and all attachments) is for the sole use of the intended recipient(s) and may contain privileged and/or proprietary information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
This email (and all attachments) is for the sole use of the intended recipient(s) and may contain privileged and/or proprietary information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
Posted by: John Viescas <johnv@msn.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (5) |
Tidak ada komentar:
Posting Komentar