LDBUser_GetUsers in Access 2007

nschroeder

nschroeder
Local time
Today, 16:31
Joined
Jan 8, 2007
Messages
186
I'm trying to utilize code from 2003 in a new 2007 database that compacts the db in the Form_Close event if there are no other users logged in. Here's the code:
Code:
Private Declare Function LDBUser_GetUsers Lib "MSLDBUSR.DLL" (lpszUserBuffer() As String, ByVal lpszFilename As String, ByVal nOptions As Long) As Integer

Private Sub Form_Close()
    If ImportOccurred Then
        Call CompactDb
    End If
End Sub

Sub CompactDb()
    On Error GoTo Err_CompactOnClose
    Application.SetOption ("Auto Compact"), 0
    ReDim lpszUserBuffer(1) As String
    UserCnt = LDBUser_GetUsers(lpszUserBuffer(), CurrentDb.Name, 2)
    If UserCnt = 1 Then ' No other users in the db
        Application.SetOption ("Auto Compact"), 1
    End If

    Exit Sub
Err_CompactOnClose:
    MsgBox Err.Number & " - " & Err.Description
End Sub

The LDBUser_GetUsers call returns a -14, which means it can't find the .ldb. Since 2007 uses a .laccdb instead of a .ldb, what do I need to change to get this to work? I've done a search for LDBUser_GetUsers and found code on how to get a list of users, but I don't need that. I just need a count. Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom