Jumat, 08 Januari 2016

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.

__._,_.___

Posted by: "Bob Phillips" <bob.phillips@dsl.pipex.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

.

__,_._,___

Tidak ada komentar:

Poskan Komentar