C# Tutorials and offshore development in India
Tutorials Resources Forum Reviews Communities Interview Jobs Projects Training Your Ad Here


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » MS Access »

List all users logged in to a MS access database


Posted Date: 12 Jun 2009    Resource Type: Code Snippets    Category: MS Access
Author: Viji RAJKUMARMember Level: Diamond    
Rating: 1 out of 5Points: 10



This function will display all users logged in to a MS Access database


Declare Function LDBUser_GetUsers Lib "MSLDBUSR.DLL" _
(lpszUserBuffer() As String, ByVal lpszFilename As String, _
ByVal nOptions As Long) As Integer

Public Function GetUsers(Optional StrDbPath As String)

ReDim lpszUserBuffer(1) As String
Dim intLooper As Integer
Dim Cusers As Long
Dim strMsgBox As String

On Error GoTo Err_GetUsers

' Check to see if a database path was passed
' to the function. If the argument was not used,
' assume that we're to investigate the .ldb
' of the current database.
If IsMissing(StrDbPath) Or StrDbPath = "" Then
StrDbPath = CurrentDb.Name
End If

' Set Cusers to the number of computers currently connected
' to the database. Insert computer information into the
' lpszUserBuffer array.

' Arguments of LdbUser_Get Users:
' 1 = All users who have logged in since the LDB file was
' created
' 2 = Only users who are currently logged in
' 4 = Only users who are causing the database file to be
' corrupted
' 8 = Just return the count of users

Cusers = LDBUser_GetUsers(lpszUserBuffer(), StrDbPath, 2)

' Print possible errors returned by the function.
Select Case Cusers
Case -1
strMsgBox = "Can't open the LDB file"
Case -2
strMsgBox = "No user connected"
Case -3
strMsgBox = "Can't Create an Array"
Case -4
strMsgBox = "Can't redimension array"
Case -5
strMsgBox = "Invalid argument passed"
Case -6
strMsgBox = "Memory allocation error"
Case -7
strMsgBox = "Bad index"
Case -8
strMsgBox = "Out of memory"
Case -9
strMsgBox = "Invalid Argument"
Case -10
strMsgBox = "LDB is suspected as corrupted"
Case -11
strMsgBox = "Invalid argument"
Case -12
strMsgBox = "Unable to read MDB file"
Case -13
strMsgBox = "Can't open the MDB file"
Case -14
strMsgBox = "Can't find the LDB file"
End Select

If Not IsEmpty(strMsgBox) And strMsgBox <> "" Then
MsgBox strMsgBox, vbCritical, "Error"
Exit Function
End If

' Print computer names to Debug window.
For intLooper = 0 To Cusers - 1
Debug.Print "User"; intLooper + 1; ":"; _
lpszUserBuffer(intLooper)
Next

Exit_GetUsers:
Exit Function
Err_GetUsers:
MsgBox Err.Description
Resume Exit_GetUsers

End Function





Responses to the resource: "List all users logged in to a MS access database"
Author: Ricop    21 Oct 2009Member Level: Bronze   Points : 0
where do i've to write this code in my access dabase?


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
List all users logged in to a MS access database  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Hide menu bars of ms access database
Previous Resource: MS Access : Remove Fields From MDB programmatically
Return to Discussion Resource Index
Post New Resource
Category: MS Access


Post resources and earn money!
 
More Resources




About Us    Contact Us    Privacy Policy    Terms Of Use