Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Who is accessing this table ?

Discussion in 'Information Technology' started by Bingo, Jul 28, 2006.

  1. Bingo

    Bingo
    Expand Collapse
    Guest

    Hi all !

    I am trying to change the structure of a table in my backend, but
    it is opened by another user (I have an error message about Access
    being unable to open the table in design view, and asking if I
    want to open it in read-only mode).
    Is there a way to know who is accessing this table ?

    Thanks a lot !

    Regards
    --
    Arnaud
     
  2. Loading...

    Similar Threads Forum Date
    As A Child, Public Marches Of Sikhism Made Me Uncomfortable. They Still Do . Why ? Whats The Logic Hard Talk Oct 16, 2016
    Arts/Society Backyard Vegetable Garden Language, Arts & Culture Dec 27, 2013
    Heritage Now a Vegetable Market, Ranjit Singh's Royal Haveli a Picture of Neglect History of Sikhism Nov 11, 2013
    Sikhism Helium: 1984 and the "Periodic Table of Hate" (Jaspreet Singh) Book Reviews & Editorials Oct 28, 2013
    Heritage How our entire history was dumped in a horse stable History of Sikhism Oct 28, 2013

  3. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    In Access 2000 and later, you can query the JET user roster:
    http://support.microsoft.com/kb/198755/en-us

    There was an LDB viewer for older versions, but it really only told you who
    had been in, not who is currently in.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Bingo" <Bingo@discussions.microsoft.com> wrote in message
    news:ek%23iHHnfGHA.2188@TK2MSFTNGP04.phx.gbl...
    > Hi all !
    >
    > I am trying to change the structure of a table in my backend, but it is
    > opened by another user (I have an error message about Access being unable
    > to open the table in design view, and asking if I want to open it in
    > read-only mode).
    > Is there a way to know who is accessing this table ?
    >
    > Thanks a lot !
    >
    > Regards
    > --
    > Arnaud
     
  4. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    Access 2k+ (Jet 4.0)
    http://support.microsoft.com/?kbid=198756

    HTH

    Pieter

    "Bingo" <Bingo@discussions.microsoft.com> wrote in message
    news:ek%23iHHnfGHA.2188@TK2MSFTNGP04.phx.gbl...
    > Hi all !
    >
    > I am trying to change the structure of a table in my backend, but it is
    > opened by another user (I have an error message about Access being unable
    > to open the table in design view, and asking if I want to open it in
    > read-only mode).
    > Is there a way to know who is accessing this table ?
    >
    > Thanks a lot !
    >
    > Regards
    > --
    > Arnaud
     
  5. Bingo

    Bingo
    Expand Collapse
    Guest

    Allen Browne a écrit :
    > In Access 2000 and later, you can query the JET user roster:
    > http://support.microsoft.com/kb/198755/en-us
    >
    > There was an LDB viewer for older versions, but it really only told you who
    > had been in, not who is currently in.


    Hi Allen,

    I have already used the User Roster, but it gives a list of all
    the users connected to the DB (and in my case, it means just
    everybody), not the ones accessing a particular table.
    Since Access is able to tell if a table is being accessed (to
    prevent design changes to it), there probably is a way to tell who
    is accessing it, isn't it ?



    Regards
    --
    Arnaud
     
  6. Bingo

    Bingo
    Expand Collapse
    Guest

    Pieter Wijnen a écrit :
    > Access 2k+ (Jet 4.0)
    > http://support.microsoft.com/?kbid=198756


    Hi Pieter !

    I have to answer the same as for Allen's suggestion : knowing who
    is connected to the DB is not enough in my case, because I already
    know that *everybody* is connected to the DB. I am trying to get a
    more precise information on who is actually accessing a specific
    table.


    Regards
    --
    Arnaud
     
  7. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    I doubt that JET for exposes more than just the user roster.
    It does not give you table-level granularity on this AFAIK.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Bingo" <Bingo@discussions.microsoft.com> wrote in message
    news:eY52lTnfGHA.1792@TK2MSFTNGP03.phx.gbl...
    > Pieter Wijnen a écrit :
    >> Access 2k+ (Jet 4.0)
    >> http://support.microsoft.com/?kbid=198756

    >
    > Hi Pieter !
    >
    > I have to answer the same as for Allen's suggestion : knowing who is
    > connected to the DB is not enough in my case, because I already know that
    > *everybody* is connected to the DB. I am trying to get a more precise
    > information on who is actually accessing a specific table.
    >
    >
    > Regards
    > --
    > Arnaud
     
  8. jonathandrott@gmail.com

    jonathandrott@gmail.com
    Expand Collapse
    Guest

    check for lock files that are not closing when you exit the program.
    usually .ldb extension.
     
  9. Bingo

    Bingo
    Expand Collapse
    Guest

    Allen Browne a écrit :
    > I doubt that JET for exposes more than just the user roster.
    > It does not give you table-level granularity on this AFAIK.


    Too bad, but I suspected this since I had not found anything on
    the net about it.
    Very inconvenient in my case...

    Regards
    --
    Arnaud
     
  10. Bingo

    Bingo
    Expand Collapse
    Guest

    jonathandrott@gmail.com a écrit :
    > check for lock files that are not closing when you exit the program.
    > usually .ldb extension.


    The program IS open, and by many users. That should not prevent me
    from changing the table structure if noone is accessing it though.

    Regards
    --
    Arnaud
     
  11. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    This I believe originally came from an article in Access Advisor: (now
    vbAdvisor) & Works for '97 as well
    I believe the core was written by Larry Kreft (or Ken Getz)
    I've converted it to a class module
    If anybody knows I'll make sure to update mine with the correct credentials

    HTH

    Pieter

    ' -----------------------

    Attribute VB_Name = "Security"
    Attribute VB_Creatable = True
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = True
    Option Compare Database
    Option Explicit
    'Security
    Private Type SECURITY_ATTRIBUTES
    nLength As Long
    lpSecurityDescriptor As Long
    bInheritHandle As Long
    End Type
    Private Type SecInfo
    bMachine(1 To 32) As Byte
    bSecurity(1 To 32) As Byte
    End Type
    Private Type OVERLAPPED
    Internal As Long
    InternalHigh As Long
    Offset As Long
    OffsetHigh As Long
    hEvent As Long
    End Type

    Private Type SecUser
    Name As String
    Machine As String
    End Type

    Private Const FILE_CURRENT = 1
    Private Const FILE_BEGIN = 0
    Private Const GENERIC_READ = &H80000000
    Private Const GENERIC_WRITE = &H40000000
    Private Const FILE_SHARE_READ = &H1
    Private Const FILE_SHARE_WRITE = &H2
    Private Const OPEN_EXISTING = 3
    Private Const FILE_FLAG_RANDOM_ACCESS = &H10000000
    Private Const FILE_ATTRIBUTE_NORMAL = &H80
    Private Const mcszSOURCE = "Security"

    Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA"
    (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal
    dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal
    dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal
    hTemplateFile As Long) As Long
    Private Declare Function SetFilePointer Lib "kernel32" (ByVal hFile As Long,
    ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal
    dwMoveMethod As Long) As Long
    Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long,
    lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As
    Long, lpOverlapped As OVERLAPPED) As Long
    Private Declare Function LockFile Lib "kernel32" (ByVal hFile As Long, ByVal
    dwFileOffsetLow As Long, ByVal dwFileOffsetHigh As Long, ByVal
    nNumberOfBytesToLockLow As Long, ByVal nNumberOfBytesToLockHigh As Long) As
    Long
    Private Declare Function UnlockFile Lib "kernel32" (ByVal hFile As Long,
    ByVal dwFileOffsetLow As Long, ByVal dwFileOffsetHigh As Long, ByVal
    nNumberOfBytesToUnlockLow As Long, ByVal nNumberOfBytesToUnlockHigh As Long)
    As Long
    Private Declare Function CloseFile Lib "kernel32" Alias "CloseHandle" (ByVal
    hFile As Long) As Long


    Private mSecurity As SECURITY_ATTRIBUTES
    Private mlFileHandle As Long
    Private mszDbName As String
    Private mszLockFile As String
    Private KeepLock As Boolean
    Property Let Database(FileName As String)
    Dim Db As DAO.Database
    If Not FileExist(FileName) Then
    VBA.Err.Raise 3024, "Security" & ".Database", "'" & FileName & "' Does
    not Exist"
    Else
    On Error Resume Next
    Set Db = Access.DBEngine.Workspaces(0).OpenDatabase(FileName, , True)
    If VBA.Err.Number <> 0 Then
    On Error GoTo 0
    VBA.Err.Raise 3343, "Security" & ".Database", "'" & FileName & "' is
    not a Database"
    End If
    mszLockFile = strRev(FileName)
    mszLockFile = strRev("bdl" & Mid(mszLockFile, InStr(mszLockFile, ".") +
    1))
    'mszLockFile = VBA.Left(FileName, VBA.InStr(FileName, ".")) & "LDB"
    mszDbName = FileName
    End If
    Db.Close: Set Db = Nothing
    End Property
    Property Get Database() As String
    Database = mszDbName
    End Property
    Private Function BytesToString(pbytArray() As Byte) As String
    On Error Resume Next
    Dim szTemp As String
    szTemp = VBA.StrConv(pbytArray(), VBA.vbUnicode)
    BytesToString = VBA.Trim(VBA.Left(szTemp, (VBA.InStr(1, szTemp,
    VBA.vbNullChar)) - 1))
    End Function
    Private Function FileExist(FileName As String) As Boolean
    On Error Resume Next
    FileExist = VBA.Len(VBA.Dir(FileName)) > 0
    End Function
    Private Function HexToLong(ByVal strHex As String) As Long
    On Error Resume Next
    HexToLong = VBA.Val("&H" & strHex & "&")
    End Function
    Private Function GetLockFile(ByVal DbName As String) As Long
    Dim mszLockFile As String
    mszLockFile = VBA.Left(DbName, VBA.InStr(DbName, ".")) & "ldb"
    mlFileHandle = CreateFile(mszLockFile, _
    GENERIC_READ Or GENERIC_WRITE, _
    FILE_SHARE_READ Or FILE_SHARE_WRITE, mSecurity,
    _
    OPEN_EXISTING, _
    FILE_FLAG_RANDOM_ACCESS Or
    FILE_ATTRIBUTE_NORMAL, 0)
    With mSecurity
    .nLength = Len(mSecurity)
    .lpSecurityDescriptor = 0
    .bInheritHandle = True
    End With
    GetLockFile = mlFileHandle
    End Function
    Private Function ReadLockingFile(ByRef UserList As Variant, Optional ByRef
    DbName As String = VBA.vbNullString, Optional ByRef UserCnt As Long = 0) As
    Long
    Dim szMachine As String, szUser As String
    Dim uSecInfo As SecInfo
    ReDim aszTempUserList(0 To 254, 0 To 2) As String
    Dim aszUserList() As String
    Dim iaCnt As Long, iCnt As Long
    Dim iOffSet As Long
    Dim lBytesRead As Long
    Dim szProcName As String
    Dim bResult As Long
    Dim uOverLapped As OVERLAPPED
    On Error GoTo 0
    szProcName = mcszSOURCE & ".ReadLockingFile"
    iOffSet = 0
    If VBA.Len(DbName) = 0 Then
    If VBA.Len(mszDbName) = 0 Then
    mszDbName = Access.CurrentDb().Name
    End If
    DbName = mszDbName
    End If
    mszDbName = DbName
    mlFileHandle = GetLockFile(DbName)
    bResult = ReadFile(mlFileHandle, uSecInfo, 64, lBytesRead, uOverLapped)
    If bResult = 0 Then
    UserCnt = 0
    UserList = Empty
    VBA.Err.Raise vbObjectError + 1050, szProcName, "Can't Read From Security
    File"
    End If
    While bResult = 1
    With uSecInfo
    aszTempUserList(iaCnt, 0) = BytesToString(.bSecurity)
    aszTempUserList(iaCnt, 1) = BytesToString(.bMachine)
    aszTempUserList(iaCnt, 2) = iOffSet
    iaCnt = iaCnt + 1
    iOffSet = iOffSet + 64
    End With
    uOverLapped.Offset = iOffSet
    bResult = ReadFile(mlFileHandle, uSecInfo, 64, lBytesRead, uOverLapped)
    Wend
    'ReDim aszTempUserList(0 To iaCnt, 0 To 2) As String
    If iaCnt > 0 Then
    ReDim Tmp(0 To iaCnt, 0 To 2) As String
    For iCnt = 0 To iaCnt - 1
    Tmp(iCnt, 0) = aszTempUserList(iCnt, 0)
    Tmp(iCnt, 1) = aszTempUserList(iCnt, 1)
    Tmp(iCnt, 2) = aszTempUserList(iCnt, 2)
    Next
    UserList = Tmp 'aszTempUserList
    Else
    UserList = Empty
    End If
    UserCnt = iaCnt
    ReadLockingFile = iaCnt

    End Function
    Function AllUsers(ByRef UserList As Variant, Optional ByRef DbName As String
    = VBA.vbNullString, Optional ByRef UserCnt As Long = 0) As Long
    On Error Resume Next
    AllUsers = ReadLockingFile(UserList, DbName, UserCnt)
    CloseFile mlFileHandle
    End Function
    Function CurrentUsers(ByRef UserList As Variant, Optional ByRef DbName As
    String = VBA.vbNullString, Optional ByRef CntUsers As Long) As Long
    Dim dwPos As Long
    Dim lLock As Long
    Dim lByte As Long
    Dim iaCnt As Long
    Dim iOffSet As Long
    ReDim aiUserLockOffset(255) As Long
    On Error Resume Next
    dwPos = &H10000001
    iaCnt = 0
    ReadLockingFile UserList, DbName, CntUsers
    If Err.Number <> 0 Then Exit Function
    For dwPos = &H10000001 To &H100000FF
    lLock = LockFile(mlFileHandle, dwPos, 0, 1, 0)
    If lLock = 0 Then
    lByte = HexToLong(VBA.Right(VBA.Hex(dwPos), 2))
    iOffSet = lByte * 64 - 64
    aiUserLockOffset(iaCnt) = iOffSet
    iaCnt = iaCnt + 1
    Else
    lLock = UnlockFile(mlFileHandle, dwPos, 0, 1, 0)
    End If
    Next dwPos
    If iaCnt = 0 Then
    UserList = Empty
    End If
    CntUsers = iaCnt
    CurrentUsers = iaCnt
    CloseFile mlFileHandle
    End Function

    Function IsUserLoggedOn(ByVal UserName As String, Optional ByRef MachineInfo
    As Variant, _
    Optional ByRef UserCount As Long = 0) As Boolean
    'ReDim pBuffer(0 To 254) As SecUser
    Dim pBuffer As Variant
    Dim iaCnt As Long, iUsrCnt As _
    Integer
    Dim bFound As Boolean, aszMachines() As String
    Dim bMachArray As Boolean, iCount As Long

    ' Handle the optional variables.
    bMachArray = False
    If Not IsMissing(MachineInfo) Then bMachArray = True

    ' Initialize variables.
    UserCount = 0
    iCount = 0
    IsUserLoggedOn = False
    bFound = False

    ' Retrieve a two-dimensional array containing all
    ' the user and machine names currently using
    ' the database.
    CurrentUsers pBuffer

    ' Retrieve count. If zero then exit function.
    If VBA.IsEmpty(pBuffer) Then Exit Function
    iUsrCnt = UBound(pBuffer, 1)

    ' Determine if User is logged on.
    ' Redim the array to hold the machine names.
    If bMachArray Then
    ReDim aszMachines(255) As String

    ' Loop through the array.
    ' Store the machine names into an array.
    For iaCnt = 0 To iUsrCnt - 1
    If VBA.UCase(UserName) = VBA.UCase(pBuffer(iaCnt, 0)) Then
    aszMachines(iCount) = pBuffer(iaCnt, 1)
    iCount = iCount + 1
    bFound = True
    End If
    Next

    If bFound Then

    ' Redim the array and return array.
    ReDim Preserve aszMachines(iCount)

    MachineInfo = aszMachines

    End If
    Else
    ' Assign the count.
    For iaCnt = 0 To iUsrCnt - 1
    If VBA.UCase(UserName) = VBA.UCase(pBuffer(iaCnt, 0)) Then
    iCount = iCount + 1
    End If
    Next

    End If

    UserCount = iCount
    IsUserLoggedOn = (UserCount > 0)

    ' Clear the arrays.
    Erase pBuffer
    Erase aszMachines

    End Function

    Property Get GetUser(Index As Byte) As String
    Dim UserList As Variant
    Dim i As Byte
    CurrentUsers UserList
    If VBA.IsEmpty(UserList) Then
    GetUser = VBA.vbNullString
    Else
    GetUser = UserList(Index, 0)
    End If
    End Property

    Property Get GetIndex(UserName As String) As Byte
    Dim UserList As Variant
    Dim i As Byte
    CurrentUsers UserList
    If VBA.IsEmpty(UserList) Then
    GetIndex = 0
    Else
    For i = 0 To UBound(UserList)
    If VBA.StrComp(VBA.UCase(UserList(i, 0)), VBA.UCase(UserName)) = 0
    Then
    GetIndex = i + 1
    Exit For
    End If
    Next 'i
    End If
    End Property

    '-----------------------------------------

    "Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message
    news:e0cg7LnfGHA.4568@TK2MSFTNGP03.phx.gbl...
    > In Access 2000 and later, you can query the JET user roster:
    > http://support.microsoft.com/kb/198755/en-us
    >
    > There was an LDB viewer for older versions, but it really only told you
    > who had been in, not who is currently in.
    >
    > --
    > Allen Browne - Microsoft MVP. Perth, Western Australia.
    > Tips for Access users - http://allenbrowne.com/tips.html
    > Reply to group, rather than allenbrowne at mvps dot org.
    >
    > "Bingo" <Bingo@discussions.microsoft.com> wrote in message
    > news:ek%23iHHnfGHA.2188@TK2MSFTNGP04.phx.gbl...
    >> Hi all !
    >>
    >> I am trying to change the structure of a table in my backend, but it is
    >> opened by another user (I have an error message about Access being unable
    >> to open the table in design view, and asking if I want to open it in
    >> read-only mode).
    >> Is there a way to know who is accessing this table ?
    >>
    >> Thanks a lot !
    >>
    >> Regards
    >> --
    >> Arnaud

    >
    >
     
  12. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    Yes, but I've never seen code to do it
    look at www.fmsinc.com maybe they've made an utility
    making design changes with user in the system is rather precarious

    Pieter

    "Bingo" <Bingo@discussions.microsoft.com> wrote in message
    news:O8asJSnfGHA.1792@TK2MSFTNGP03.phx.gbl...
    > Allen Browne a écrit :
    >> In Access 2000 and later, you can query the JET user roster:
    >> http://support.microsoft.com/kb/198755/en-us
    >>
    >> There was an LDB viewer for older versions, but it really only told you
    >> who had been in, not who is currently in.

    >
    > Hi Allen,
    >
    > I have already used the User Roster, but it gives a list of all the users
    > connected to the DB (and in my case, it means just everybody), not the
    > ones accessing a particular table.
    > Since Access is able to tell if a table is being accessed (to prevent
    > design changes to it), there probably is a way to tell who is accessing
    > it, isn't it ?
    >
    >
    >
    > Regards
    > --
    > Arnaud
     
  13. Douglas J Steele

    Douglas J Steele
    Expand Collapse
    Guest

    Check http://www.mvps.org/access/modules/mdl0055.htm at "The Access Web".
    You might not have to...

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "Pieter Wijnen"
    <it.isi.llegal.to.send.unsollicited.mail.wijnen.nospam.please@online.replace
    ..with.norway> wrote in message news:unORolnfGHA.4276@TK2MSFTNGP03.phx.gbl...
    >
    > This I believe originally came from an article in Access Advisor: (now
    > vbAdvisor) & Works for '97 as well
    > I believe the core was written by Larry Kreft (or Ken Getz)
    > I've converted it to a class module
    > If anybody knows I'll make sure to update mine with the correct

    credentials
    >
    > HTH
    >
    > Pieter
    >
    > ' -----------------------
    >
    > Attribute VB_Name = "Security"
    > Attribute VB_Creatable = True
    > Attribute VB_PredeclaredId = True
    > Attribute VB_Exposed = True
    > Option Compare Database
    > Option Explicit
    > 'Security
    > Private Type SECURITY_ATTRIBUTES
    > nLength As Long
    > lpSecurityDescriptor As Long
    > bInheritHandle As Long
    > End Type
    > Private Type SecInfo
    > bMachine(1 To 32) As Byte
    > bSecurity(1 To 32) As Byte
    > End Type
    > Private Type OVERLAPPED
    > Internal As Long
    > InternalHigh As Long
    > Offset As Long
    > OffsetHigh As Long
    > hEvent As Long
    > End Type
    >
    > Private Type SecUser
    > Name As String
    > Machine As String
    > End Type
    >
    > Private Const FILE_CURRENT = 1
    > Private Const FILE_BEGIN = 0
    > Private Const GENERIC_READ = &H80000000
    > Private Const GENERIC_WRITE = &H40000000
    > Private Const FILE_SHARE_READ = &H1
    > Private Const FILE_SHARE_WRITE = &H2
    > Private Const OPEN_EXISTING = 3
    > Private Const FILE_FLAG_RANDOM_ACCESS = &H10000000
    > Private Const FILE_ATTRIBUTE_NORMAL = &H80
    > Private Const mcszSOURCE = "Security"
    >
    > Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA"
    > (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal
    > dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal
    > dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal
    > hTemplateFile As Long) As Long
    > Private Declare Function SetFilePointer Lib "kernel32" (ByVal hFile As

    Long,
    > ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal
    > dwMoveMethod As Long) As Long
    > Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long,
    > lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead

    As
    > Long, lpOverlapped As OVERLAPPED) As Long
    > Private Declare Function LockFile Lib "kernel32" (ByVal hFile As Long,

    ByVal
    > dwFileOffsetLow As Long, ByVal dwFileOffsetHigh As Long, ByVal
    > nNumberOfBytesToLockLow As Long, ByVal nNumberOfBytesToLockHigh As Long)

    As
    > Long
    > Private Declare Function UnlockFile Lib "kernel32" (ByVal hFile As Long,
    > ByVal dwFileOffsetLow As Long, ByVal dwFileOffsetHigh As Long, ByVal
    > nNumberOfBytesToUnlockLow As Long, ByVal nNumberOfBytesToUnlockHigh As

    Long)
    > As Long
    > Private Declare Function CloseFile Lib "kernel32" Alias "CloseHandle"

    (ByVal
    > hFile As Long) As Long
    >
    >
    > Private mSecurity As SECURITY_ATTRIBUTES
    > Private mlFileHandle As Long
    > Private mszDbName As String
    > Private mszLockFile As String
    > Private KeepLock As Boolean
    > Property Let Database(FileName As String)
    > Dim Db As DAO.Database
    > If Not FileExist(FileName) Then
    > VBA.Err.Raise 3024, "Security" & ".Database", "'" & FileName & "' Does
    > not Exist"
    > Else
    > On Error Resume Next
    > Set Db = Access.DBEngine.Workspaces(0).OpenDatabase(FileName, , True)
    > If VBA.Err.Number <> 0 Then
    > On Error GoTo 0
    > VBA.Err.Raise 3343, "Security" & ".Database", "'" & FileName & "' is
    > not a Database"
    > End If
    > mszLockFile = strRev(FileName)
    > mszLockFile = strRev("bdl" & Mid(mszLockFile, InStr(mszLockFile, ".")

    +
    > 1))
    > 'mszLockFile = VBA.Left(FileName, VBA.InStr(FileName, ".")) & "LDB"
    > mszDbName = FileName
    > End If
    > Db.Close: Set Db = Nothing
    > End Property
    > Property Get Database() As String
    > Database = mszDbName
    > End Property
    > Private Function BytesToString(pbytArray() As Byte) As String
    > On Error Resume Next
    > Dim szTemp As String
    > szTemp = VBA.StrConv(pbytArray(), VBA.vbUnicode)
    > BytesToString = VBA.Trim(VBA.Left(szTemp, (VBA.InStr(1, szTemp,
    > VBA.vbNullChar)) - 1))
    > End Function
    > Private Function FileExist(FileName As String) As Boolean
    > On Error Resume Next
    > FileExist = VBA.Len(VBA.Dir(FileName)) > 0
    > End Function
    > Private Function HexToLong(ByVal strHex As String) As Long
    > On Error Resume Next
    > HexToLong = VBA.Val("&H" & strHex & "&")
    > End Function
    > Private Function GetLockFile(ByVal DbName As String) As Long
    > Dim mszLockFile As String
    > mszLockFile = VBA.Left(DbName, VBA.InStr(DbName, ".")) & "ldb"
    > mlFileHandle = CreateFile(mszLockFile, _
    > GENERIC_READ Or GENERIC_WRITE, _
    > FILE_SHARE_READ Or FILE_SHARE_WRITE,

    mSecurity,
    > _
    > OPEN_EXISTING, _
    > FILE_FLAG_RANDOM_ACCESS Or
    > FILE_ATTRIBUTE_NORMAL, 0)
    > With mSecurity
    > .nLength = Len(mSecurity)
    > .lpSecurityDescriptor = 0
    > .bInheritHandle = True
    > End With
    > GetLockFile = mlFileHandle
    > End Function
    > Private Function ReadLockingFile(ByRef UserList As Variant, Optional ByRef
    > DbName As String = VBA.vbNullString, Optional ByRef UserCnt As Long = 0)

    As
    > Long
    > Dim szMachine As String, szUser As String
    > Dim uSecInfo As SecInfo
    > ReDim aszTempUserList(0 To 254, 0 To 2) As String
    > Dim aszUserList() As String
    > Dim iaCnt As Long, iCnt As Long
    > Dim iOffSet As Long
    > Dim lBytesRead As Long
    > Dim szProcName As String
    > Dim bResult As Long
    > Dim uOverLapped As OVERLAPPED
    > On Error GoTo 0
    > szProcName = mcszSOURCE & ".ReadLockingFile"
    > iOffSet = 0
    > If VBA.Len(DbName) = 0 Then
    > If VBA.Len(mszDbName) = 0 Then
    > mszDbName = Access.CurrentDb().Name
    > End If
    > DbName = mszDbName
    > End If
    > mszDbName = DbName
    > mlFileHandle = GetLockFile(DbName)
    > bResult = ReadFile(mlFileHandle, uSecInfo, 64, lBytesRead, uOverLapped)
    > If bResult = 0 Then
    > UserCnt = 0
    > UserList = Empty
    > VBA.Err.Raise vbObjectError + 1050, szProcName, "Can't Read From

    Security
    > File"
    > End If
    > While bResult = 1
    > With uSecInfo
    > aszTempUserList(iaCnt, 0) = BytesToString(.bSecurity)
    > aszTempUserList(iaCnt, 1) = BytesToString(.bMachine)
    > aszTempUserList(iaCnt, 2) = iOffSet
    > iaCnt = iaCnt + 1
    > iOffSet = iOffSet + 64
    > End With
    > uOverLapped.Offset = iOffSet
    > bResult = ReadFile(mlFileHandle, uSecInfo, 64, lBytesRead,

    uOverLapped)
    > Wend
    > 'ReDim aszTempUserList(0 To iaCnt, 0 To 2) As String
    > If iaCnt > 0 Then
    > ReDim Tmp(0 To iaCnt, 0 To 2) As String
    > For iCnt = 0 To iaCnt - 1
    > Tmp(iCnt, 0) = aszTempUserList(iCnt, 0)
    > Tmp(iCnt, 1) = aszTempUserList(iCnt, 1)
    > Tmp(iCnt, 2) = aszTempUserList(iCnt, 2)
    > Next
    > UserList = Tmp 'aszTempUserList
    > Else
    > UserList = Empty
    > End If
    > UserCnt = iaCnt
    > ReadLockingFile = iaCnt
    >
    > End Function
    > Function AllUsers(ByRef UserList As Variant, Optional ByRef DbName As

    String
    > = VBA.vbNullString, Optional ByRef UserCnt As Long = 0) As Long
    > On Error Resume Next
    > AllUsers = ReadLockingFile(UserList, DbName, UserCnt)
    > CloseFile mlFileHandle
    > End Function
    > Function CurrentUsers(ByRef UserList As Variant, Optional ByRef DbName As
    > String = VBA.vbNullString, Optional ByRef CntUsers As Long) As Long
    > Dim dwPos As Long
    > Dim lLock As Long
    > Dim lByte As Long
    > Dim iaCnt As Long
    > Dim iOffSet As Long
    > ReDim aiUserLockOffset(255) As Long
    > On Error Resume Next
    > dwPos = &H10000001
    > iaCnt = 0
    > ReadLockingFile UserList, DbName, CntUsers
    > If Err.Number <> 0 Then Exit Function
    > For dwPos = &H10000001 To &H100000FF
    > lLock = LockFile(mlFileHandle, dwPos, 0, 1, 0)
    > If lLock = 0 Then
    > lByte = HexToLong(VBA.Right(VBA.Hex(dwPos), 2))
    > iOffSet = lByte * 64 - 64
    > aiUserLockOffset(iaCnt) = iOffSet
    > iaCnt = iaCnt + 1
    > Else
    > lLock = UnlockFile(mlFileHandle, dwPos, 0, 1, 0)
    > End If
    > Next dwPos
    > If iaCnt = 0 Then
    > UserList = Empty
    > End If
    > CntUsers = iaCnt
    > CurrentUsers = iaCnt
    > CloseFile mlFileHandle
    > End Function
    >
    > Function IsUserLoggedOn(ByVal UserName As String, Optional ByRef

    MachineInfo
    > As Variant, _
    > Optional ByRef UserCount As Long = 0) As Boolean
    > 'ReDim pBuffer(0 To 254) As SecUser
    > Dim pBuffer As Variant
    > Dim iaCnt As Long, iUsrCnt As _
    > Integer
    > Dim bFound As Boolean, aszMachines() As String
    > Dim bMachArray As Boolean, iCount As Long
    >
    > ' Handle the optional variables.
    > bMachArray = False
    > If Not IsMissing(MachineInfo) Then bMachArray = True
    >
    > ' Initialize variables.
    > UserCount = 0
    > iCount = 0
    > IsUserLoggedOn = False
    > bFound = False
    >
    > ' Retrieve a two-dimensional array containing all
    > ' the user and machine names currently using
    > ' the database.
    > CurrentUsers pBuffer
    >
    > ' Retrieve count. If zero then exit function.
    > If VBA.IsEmpty(pBuffer) Then Exit Function
    > iUsrCnt = UBound(pBuffer, 1)
    >
    > ' Determine if User is logged on.
    > ' Redim the array to hold the machine names.
    > If bMachArray Then
    > ReDim aszMachines(255) As String
    >
    > ' Loop through the array.
    > ' Store the machine names into an array.
    > For iaCnt = 0 To iUsrCnt - 1
    > If VBA.UCase(UserName) = VBA.UCase(pBuffer(iaCnt, 0)) Then
    > aszMachines(iCount) = pBuffer(iaCnt, 1)
    > iCount = iCount + 1
    > bFound = True
    > End If
    > Next
    >
    > If bFound Then
    >
    > ' Redim the array and return array.
    > ReDim Preserve aszMachines(iCount)
    >
    > MachineInfo = aszMachines
    >
    > End If
    > Else
    > ' Assign the count.
    > For iaCnt = 0 To iUsrCnt - 1
    > If VBA.UCase(UserName) = VBA.UCase(pBuffer(iaCnt, 0)) Then
    > iCount = iCount + 1
    > End If
    > Next
    >
    > End If
    >
    > UserCount = iCount
    > IsUserLoggedOn = (UserCount > 0)
    >
    > ' Clear the arrays.
    > Erase pBuffer
    > Erase aszMachines
    >
    > End Function
    >
    > Property Get GetUser(Index As Byte) As String
    > Dim UserList As Variant
    > Dim i As Byte
    > CurrentUsers UserList
    > If VBA.IsEmpty(UserList) Then
    > GetUser = VBA.vbNullString
    > Else
    > GetUser = UserList(Index, 0)
    > End If
    > End Property
    >
    > Property Get GetIndex(UserName As String) As Byte
    > Dim UserList As Variant
    > Dim i As Byte
    > CurrentUsers UserList
    > If VBA.IsEmpty(UserList) Then
    > GetIndex = 0
    > Else
    > For i = 0 To UBound(UserList)
    > If VBA.StrComp(VBA.UCase(UserList(i, 0)), VBA.UCase(UserName)) = 0
    > Then
    > GetIndex = i + 1
    > Exit For
    > End If
    > Next 'i
    > End If
    > End Property
    >
    > '-----------------------------------------
    >
    > "Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message
    > news:e0cg7LnfGHA.4568@TK2MSFTNGP03.phx.gbl...
    > > In Access 2000 and later, you can query the JET user roster:
    > > http://support.microsoft.com/kb/198755/en-us
    > >
    > > There was an LDB viewer for older versions, but it really only told you
    > > who had been in, not who is currently in.
    > >
    > > --
    > > Allen Browne - Microsoft MVP. Perth, Western Australia.
    > > Tips for Access users - http://allenbrowne.com/tips.html
    > > Reply to group, rather than allenbrowne at mvps dot org.
    > >
    > > "Bingo" <Bingo@discussions.microsoft.com> wrote in message
    > > news:ek%23iHHnfGHA.2188@TK2MSFTNGP04.phx.gbl...
    > >> Hi all !
    > >>
    > >> I am trying to change the structure of a table in my backend, but it is
    > >> opened by another user (I have an error message about Access being

    unable
    > >> to open the table in design view, and asking if I want to open it in
    > >> read-only mode).
    > >> Is there a way to know who is accessing this table ?
    > >>
    > >> Thanks a lot !
    > >>
    > >> Regards
    > >> --
    > >> Arnaud

    > >
    > >

    >
    >
     
  14. Bingo

    Bingo
    Expand Collapse
    Guest

    Pieter Wijnen a écrit :
    > Yes, but I've never seen code to do it
    > look at www.fmsinc.com maybe they've made an utility
    > making design changes with user in the system is rather precarious



    Sure, I just want to know who is "in" to tell him to disconnect.
    Thanks for the link, I'm downloading one of their tools. I hope it
    works !

    Regards
    --
    Arnaud
     
  15. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    I asked Dev at least 8 years ago to put it there, so I didn't expect to ever
    see it <g>
    It might just have been Michael Kaplan who was the original source (lost my
    copy of the mag a long time ago)

    Pieter

    "Douglas J Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
    news:OYeWFpnfGHA.2032@TK2MSFTNGP02.phx.gbl...
    > Check http://www.mvps.org/access/modules/mdl0055.htm at "The Access Web".
    > You might not have to...
    >
    > --
    > Doug Steele, Microsoft Access MVP
    > http://I.Am/DougSteele
    > (no e-mails, please!)
    >
    >
    > "Pieter Wijnen"
    > <it.isi.llegal.to.send.unsollicited.mail.wijnen.nospam.please@online.replace
    > .with.norway> wrote in message
    > news:unORolnfGHA.4276@TK2MSFTNGP03.phx.gbl...
    >>
    >> This I believe originally came from an article in Access Advisor: (now
    >> vbAdvisor) & Works for '97 as well
    >> I believe the core was written by Larry Kreft (or Ken Getz)
    >> I've converted it to a class module
    >> If anybody knows I'll make sure to update mine with the correct

    > credentials
    >>
    >> HTH
    >>
    >> Pieter
    >>
    >> ' -----------------------
    >>
    >> Attribute VB_Name = "Security"
    >> Attribute VB_Creatable = True
    >> Attribute VB_PredeclaredId = True
    >> Attribute VB_Exposed = True
    >> Option Compare Database
    >> Option Explicit
    >> 'Security
    >> Private Type SECURITY_ATTRIBUTES
    >> nLength As Long
    >> lpSecurityDescriptor As Long
    >> bInheritHandle As Long
    >> End Type
    >> Private Type SecInfo
    >> bMachine(1 To 32) As Byte
    >> bSecurity(1 To 32) As Byte
    >> End Type
    >> Private Type OVERLAPPED
    >> Internal As Long
    >> InternalHigh As Long
    >> Offset As Long
    >> OffsetHigh As Long
    >> hEvent As Long
    >> End Type
    >>
    >> Private Type SecUser
    >> Name As String
    >> Machine As String
    >> End Type
    >>
    >> Private Const FILE_CURRENT = 1
    >> Private Const FILE_BEGIN = 0
    >> Private Const GENERIC_READ = &H80000000
    >> Private Const GENERIC_WRITE = &H40000000
    >> Private Const FILE_SHARE_READ = &H1
    >> Private Const FILE_SHARE_WRITE = &H2
    >> Private Const OPEN_EXISTING = 3
    >> Private Const FILE_FLAG_RANDOM_ACCESS = &H10000000
    >> Private Const FILE_ATTRIBUTE_NORMAL = &H80
    >> Private Const mcszSOURCE = "Security"
    >>
    >> Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA"
    >> (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal
    >> dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal
    >> dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal
    >> hTemplateFile As Long) As Long
    >> Private Declare Function SetFilePointer Lib "kernel32" (ByVal hFile As

    > Long,
    >> ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal
    >> dwMoveMethod As Long) As Long
    >> Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long,
    >> lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead

    > As
    >> Long, lpOverlapped As OVERLAPPED) As Long
    >> Private Declare Function LockFile Lib "kernel32" (ByVal hFile As Long,

    > ByVal
    >> dwFileOffsetLow As Long, ByVal dwFileOffsetHigh As Long, ByVal
    >> nNumberOfBytesToLockLow As Long, ByVal nNumberOfBytesToLockHigh As Long)

    > As
    >> Long
    >> Private Declare Function UnlockFile Lib "kernel32" (ByVal hFile As Long,
    >> ByVal dwFileOffsetLow As Long, ByVal dwFileOffsetHigh As Long, ByVal
    >> nNumberOfBytesToUnlockLow As Long, ByVal nNumberOfBytesToUnlockHigh As

    > Long)
    >> As Long
    >> Private Declare Function CloseFile Lib "kernel32" Alias "CloseHandle"

    > (ByVal
    >> hFile As Long) As Long
    >>
    >>
    >> Private mSecurity As SECURITY_ATTRIBUTES
    >> Private mlFileHandle As Long
    >> Private mszDbName As String
    >> Private mszLockFile As String
    >> Private KeepLock As Boolean
    >> Property Let Database(FileName As String)
    >> Dim Db As DAO.Database
    >> If Not FileExist(FileName) Then
    >> VBA.Err.Raise 3024, "Security" & ".Database", "'" & FileName & "' Does
    >> not Exist"
    >> Else
    >> On Error Resume Next
    >> Set Db = Access.DBEngine.Workspaces(0).OpenDatabase(FileName, , True)
    >> If VBA.Err.Number <> 0 Then
    >> On Error GoTo 0
    >> VBA.Err.Raise 3343, "Security" & ".Database", "'" & FileName & "' is
    >> not a Database"
    >> End If
    >> mszLockFile = strRev(FileName)
    >> mszLockFile = strRev("bdl" & Mid(mszLockFile, InStr(mszLockFile, ".")

    > +
    >> 1))
    >> 'mszLockFile = VBA.Left(FileName, VBA.InStr(FileName, ".")) & "LDB"
    >> mszDbName = FileName
    >> End If
    >> Db.Close: Set Db = Nothing
    >> End Property
    >> Property Get Database() As String
    >> Database = mszDbName
    >> End Property
    >> Private Function BytesToString(pbytArray() As Byte) As String
    >> On Error Resume Next
    >> Dim szTemp As String
    >> szTemp = VBA.StrConv(pbytArray(), VBA.vbUnicode)
    >> BytesToString = VBA.Trim(VBA.Left(szTemp, (VBA.InStr(1, szTemp,
    >> VBA.vbNullChar)) - 1))
    >> End Function
    >> Private Function FileExist(FileName As String) As Boolean
    >> On Error Resume Next
    >> FileExist = VBA.Len(VBA.Dir(FileName)) > 0
    >> End Function
    >> Private Function HexToLong(ByVal strHex As String) As Long
    >> On Error Resume Next
    >> HexToLong = VBA.Val("&H" & strHex & "&")
    >> End Function
    >> Private Function GetLockFile(ByVal DbName As String) As Long
    >> Dim mszLockFile As String
    >> mszLockFile = VBA.Left(DbName, VBA.InStr(DbName, ".")) & "ldb"
    >> mlFileHandle = CreateFile(mszLockFile, _
    >> GENERIC_READ Or GENERIC_WRITE, _
    >> FILE_SHARE_READ Or FILE_SHARE_WRITE,

    > mSecurity,
    >> _
    >> OPEN_EXISTING, _
    >> FILE_FLAG_RANDOM_ACCESS Or
    >> FILE_ATTRIBUTE_NORMAL, 0)
    >> With mSecurity
    >> .nLength = Len(mSecurity)
    >> .lpSecurityDescriptor = 0
    >> .bInheritHandle = True
    >> End With
    >> GetLockFile = mlFileHandle
    >> End Function
    >> Private Function ReadLockingFile(ByRef UserList As Variant, Optional
    >> ByRef
    >> DbName As String = VBA.vbNullString, Optional ByRef UserCnt As Long = 0)

    > As
    >> Long
    >> Dim szMachine As String, szUser As String
    >> Dim uSecInfo As SecInfo
    >> ReDim aszTempUserList(0 To 254, 0 To 2) As String
    >> Dim aszUserList() As String
    >> Dim iaCnt As Long, iCnt As Long
    >> Dim iOffSet As Long
    >> Dim lBytesRead As Long
    >> Dim szProcName As String
    >> Dim bResult As Long
    >> Dim uOverLapped As OVERLAPPED
    >> On Error GoTo 0
    >> szProcName = mcszSOURCE & ".ReadLockingFile"
    >> iOffSet = 0
    >> If VBA.Len(DbName) = 0 Then
    >> If VBA.Len(mszDbName) = 0 Then
    >> mszDbName = Access.CurrentDb().Name
    >> End If
    >> DbName = mszDbName
    >> End If
    >> mszDbName = DbName
    >> mlFileHandle = GetLockFile(DbName)
    >> bResult = ReadFile(mlFileHandle, uSecInfo, 64, lBytesRead, uOverLapped)
    >> If bResult = 0 Then
    >> UserCnt = 0
    >> UserList = Empty
    >> VBA.Err.Raise vbObjectError + 1050, szProcName, "Can't Read From

    > Security
    >> File"
    >> End If
    >> While bResult = 1
    >> With uSecInfo
    >> aszTempUserList(iaCnt, 0) = BytesToString(.bSecurity)
    >> aszTempUserList(iaCnt, 1) = BytesToString(.bMachine)
    >> aszTempUserList(iaCnt, 2) = iOffSet
    >> iaCnt = iaCnt + 1
    >> iOffSet = iOffSet + 64
    >> End With
    >> uOverLapped.Offset = iOffSet
    >> bResult = ReadFile(mlFileHandle, uSecInfo, 64, lBytesRead,

    > uOverLapped)
    >> Wend
    >> 'ReDim aszTempUserList(0 To iaCnt, 0 To 2) As String
    >> If iaCnt > 0 Then
    >> ReDim Tmp(0 To iaCnt, 0 To 2) As String
    >> For iCnt = 0 To iaCnt - 1
    >> Tmp(iCnt, 0) = aszTempUserList(iCnt, 0)
    >> Tmp(iCnt, 1) = aszTempUserList(iCnt, 1)
    >> Tmp(iCnt, 2) = aszTempUserList(iCnt, 2)
    >> Next
    >> UserList = Tmp 'aszTempUserList
    >> Else
    >> UserList = Empty
    >> End If
    >> UserCnt = iaCnt
    >> ReadLockingFile = iaCnt
    >>
    >> End Function
    >> Function AllUsers(ByRef UserList As Variant, Optional ByRef DbName As

    > String
    >> = VBA.vbNullString, Optional ByRef UserCnt As Long = 0) As Long
    >> On Error Resume Next
    >> AllUsers = ReadLockingFile(UserList, DbName, UserCnt)
    >> CloseFile mlFileHandle
    >> End Function
    >> Function CurrentUsers(ByRef UserList As Variant, Optional ByRef DbName As
    >> String = VBA.vbNullString, Optional ByRef CntUsers As Long) As Long
    >> Dim dwPos As Long
    >> Dim lLock As Long
    >> Dim lByte As Long
    >> Dim iaCnt As Long
    >> Dim iOffSet As Long
    >> ReDim aiUserLockOffset(255) As Long
    >> On Error Resume Next
    >> dwPos = &H10000001
    >> iaCnt = 0
    >> ReadLockingFile UserList, DbName, CntUsers
    >> If Err.Number <> 0 Then Exit Function
    >> For dwPos = &H10000001 To &H100000FF
    >> lLock = LockFile(mlFileHandle, dwPos, 0, 1, 0)
    >> If lLock = 0 Then
    >> lByte = HexToLong(VBA.Right(VBA.Hex(dwPos), 2))
    >> iOffSet = lByte * 64 - 64
    >> aiUserLockOffset(iaCnt) = iOffSet
    >> iaCnt = iaCnt + 1
    >> Else
    >> lLock = UnlockFile(mlFileHandle, dwPos, 0, 1, 0)
    >> End If
    >> Next dwPos
    >> If iaCnt = 0 Then
    >> UserList = Empty
    >> End If
    >> CntUsers = iaCnt
    >> CurrentUsers = iaCnt
    >> CloseFile mlFileHandle
    >> End Function
    >>
    >> Function IsUserLoggedOn(ByVal UserName As String, Optional ByRef

    > MachineInfo
    >> As Variant, _
    >> Optional ByRef UserCount As Long = 0) As Boolean
    >> 'ReDim pBuffer(0 To 254) As SecUser
    >> Dim pBuffer As Variant
    >> Dim iaCnt As Long, iUsrCnt As _
    >> Integer
    >> Dim bFound As Boolean, aszMachines() As String
    >> Dim bMachArray As Boolean, iCount As Long
    >>
    >> ' Handle the optional variables.
    >> bMachArray = False
    >> If Not IsMissing(MachineInfo) Then bMachArray = True
    >>
    >> ' Initialize variables.
    >> UserCount = 0
    >> iCount = 0
    >> IsUserLoggedOn = False
    >> bFound = False
    >>
    >> ' Retrieve a two-dimensional array containing all
    >> ' the user and machine names currently using
    >> ' the database.
    >> CurrentUsers pBuffer
    >>
    >> ' Retrieve count. If zero then exit function.
    >> If VBA.IsEmpty(pBuffer) Then Exit Function
    >> iUsrCnt = UBound(pBuffer, 1)
    >>
    >> ' Determine if User is logged on.
    >> ' Redim the array to hold the machine names.
    >> If bMachArray Then
    >> ReDim aszMachines(255) As String
    >>
    >> ' Loop through the array.
    >> ' Store the machine names into an array.
    >> For iaCnt = 0 To iUsrCnt - 1
    >> If VBA.UCase(UserName) = VBA.UCase(pBuffer(iaCnt, 0)) Then
    >> aszMachines(iCount) = pBuffer(iaCnt, 1)
    >> iCount = iCount + 1
    >> bFound = True
    >> End If
    >> Next
    >>
    >> If bFound Then
    >>
    >> ' Redim the array and return array.
    >> ReDim Preserve aszMachines(iCount)
    >>
    >> MachineInfo = aszMachines
    >>
    >> End If
    >> Else
    >> ' Assign the count.
    >> For iaCnt = 0 To iUsrCnt - 1
    >> If VBA.UCase(UserName) = VBA.UCase(pBuffer(iaCnt, 0)) Then
    >> iCount = iCount + 1
    >> End If
    >> Next
    >>
    >> End If
    >>
    >> UserCount = iCount
    >> IsUserLoggedOn = (UserCount > 0)
    >>
    >> ' Clear the arrays.
    >> Erase pBuffer
    >> Erase aszMachines
    >>
    >> End Function
    >>
    >> Property Get GetUser(Index As Byte) As String
    >> Dim UserList As Variant
    >> Dim i As Byte
    >> CurrentUsers UserList
    >> If VBA.IsEmpty(UserList) Then
    >> GetUser = VBA.vbNullString
    >> Else
    >> GetUser = UserList(Index, 0)
    >> End If
    >> End Property
    >>
    >> Property Get GetIndex(UserName As String) As Byte
    >> Dim UserList As Variant
    >> Dim i As Byte
    >> CurrentUsers UserList
    >> If VBA.IsEmpty(UserList) Then
    >> GetIndex = 0
    >> Else
    >> For i = 0 To UBound(UserList)
    >> If VBA.StrComp(VBA.UCase(UserList(i, 0)), VBA.UCase(UserName)) = 0
    >> Then
    >> GetIndex = i + 1
    >> Exit For
    >> End If
    >> Next 'i
    >> End If
    >> End Property
    >>
    >> '-----------------------------------------
    >>
    >> "Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message
    >> news:e0cg7LnfGHA.4568@TK2MSFTNGP03.phx.gbl...
    >> > In Access 2000 and later, you can query the JET user roster:
    >> > http://support.microsoft.com/kb/198755/en-us
    >> >
    >> > There was an LDB viewer for older versions, but it really only told you
    >> > who had been in, not who is currently in.
    >> >
    >> > --
    >> > Allen Browne - Microsoft MVP. Perth, Western Australia.
    >> > Tips for Access users - http://allenbrowne.com/tips.html
    >> > Reply to group, rather than allenbrowne at mvps dot org.
    >> >
    >> > "Bingo" <Bingo@discussions.microsoft.com> wrote in message
    >> > news:ek%23iHHnfGHA.2188@TK2MSFTNGP04.phx.gbl...
    >> >> Hi all !
    >> >>
    >> >> I am trying to change the structure of a table in my backend, but it
    >> >> is
    >> >> opened by another user (I have an error message about Access being

    > unable
    >> >> to open the table in design view, and asking if I want to open it in
    >> >> read-only mode).
    >> >> Is there a way to know who is accessing this table ?
    >> >>
    >> >> Thanks a lot !
    >> >>
    >> >> Regards
    >> >> --
    >> >> Arnaud
    >> >
    >> >

    >>
    >>

    >
    >
     
  16. Andrew Tapp

    Andrew Tapp
    Expand Collapse
    Guest

    Try the following link;
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q176670

    It is applicable to Jet 2.x and 3.x and contains a white paper on
    'Understanding Microsoft Jet Locking' by Kevin Collins which may provide some
    insight for you, some of the other utilities may be of help.

    Hope this helps.

    "Bingo" wrote:

    > Allen Browne a écrit :
    > > I doubt that JET for exposes more than just the user roster.
    > > It does not give you table-level granularity on this AFAIK.

    >
    > Too bad, but I suspected this since I had not found anything on
    > the net about it.
    > Very inconvenient in my case...
    >
    > Regards
    > --
    > Arnaud
    >
     

Share This Page