473,327 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Currently Logged on Users in Access ADO ADP

In my MS Access2000 MDB Files I used the code below to populate a list
box of all logged on users. Can anyone help me figure out a way to
modify the code to do the same with my MS Access2000 ADP Project.
Any help is appreciated.
lq

'CODE START

Function WhosOn() As String
On Error GoTo Err_WhosOn
'reads *.LDB file and read who is currently logged on and their
station name - the LDB file has a 64 byte record

Dim iLDBFile As Integer, iStart As Integer
Dim iLOF As Integer, i As Integer
Dim sPath As String, X As String
Dim sLogStr As String, sLogins As String
Dim sMach As String, sUser As String
Dim rUser As UserRec
Dim td As TableDef
Dim dbcurrent As dao.Database

Set dbcurrent = DBEngine.Workspaces(0).Databases(0)
'use this for current database:
'*sPath = dbCurrent.Name

'use this for networked database:
For Each td In dbcurrent.TableDefs
If Len(td.Connect) > 0 Then 'is a linked table
On Error Resume Next
sPath = right(td.Connect, Len(td.Connect) - 10) 'check
file name
On Error GoTo Err_WhosOn
GoTo nextstep:
End If
Next 'loop to next tabledef
GoTo nextstep:
nextstep:
dbcurrent.Close

'iterate thru dbCurrent.LDB file for login names.

sPath = Left$(sPath, InStr(1, sPath, ".")) + "LDB"

'test for valid file, else Error

X = Dir(sPath)
iStart = 1
iLDBFile = FreeFile

Open sPath For Binary Access Read Shared As iLDBFile
iLOF = LOF(iLDBFile)
Do While Not EOF(iLDBFile)
Get iLDBFile, , rUser
With rUser
i = 1
sMach = ""
While .bMach(i) <> 0
sMach = sMach & Chr(.bMach(i))
i = i + 1
Wend
i = 1
sUser = ""
While .bUser(i) <> 0
sUser = sUser & Chr(.bUser(i))
i = i + 1
Wend
End With
sLogStr = sMach & " -- " & sUser
If InStr(sLogins, sLogStr) = 0 Then
sLogins = sLogins & sLogStr & ";"
End If
iStart = iStart + 64 '>increment to next record offset
Loop
Close iLDBFile
WhosOn = sLogins

Exit_WhosOn:
Exit Function
Err_WhosOn:
If Err = 68 Then
MsgBox "Couldn't populate the list", 48, "No LDB File"
Else
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
Close iLDBFile
End If
Resume Exit_WhosOn
End Function

'CODE END
Nov 12 '05 #1
2 6266
Lauren -

Tried the code for fun, but get an error on

Dim rUser As UserRec

Where is type UserRec defined?

- jtp

"Lauren Quantrell" <la*************@hotmail.com> wrote in message
news:47**************************@posting.google.c om...
In my MS Access2000 MDB Files I used the code below to populate a list
box of all logged on users. Can anyone help me figure out a way to
modify the code to do the same with my MS Access2000 ADP Project.
Any help is appreciated.
lq

'CODE START

Function WhosOn() As String
On Error GoTo Err_WhosOn
'reads *.LDB file and read who is currently logged on and their
station name - the LDB file has a 64 byte record

Dim iLDBFile As Integer, iStart As Integer
Dim iLOF As Integer, i As Integer
Dim sPath As String, X As String
Dim sLogStr As String, sLogins As String
Dim sMach As String, sUser As String
Dim rUser As UserRec
Dim td As TableDef
Dim dbcurrent As dao.Database

Set dbcurrent = DBEngine.Workspaces(0).Databases(0)
'use this for current database:
'*sPath = dbCurrent.Name

'use this for networked database:
For Each td In dbcurrent.TableDefs
If Len(td.Connect) > 0 Then 'is a linked table
On Error Resume Next
sPath = right(td.Connect, Len(td.Connect) - 10) 'check
file name
On Error GoTo Err_WhosOn
GoTo nextstep:
End If
Next 'loop to next tabledef
GoTo nextstep:
nextstep:
dbcurrent.Close

'iterate thru dbCurrent.LDB file for login names.

sPath = Left$(sPath, InStr(1, sPath, ".")) + "LDB"

'test for valid file, else Error

X = Dir(sPath)
iStart = 1
iLDBFile = FreeFile

Open sPath For Binary Access Read Shared As iLDBFile
iLOF = LOF(iLDBFile)
Do While Not EOF(iLDBFile)
Get iLDBFile, , rUser
With rUser
i = 1
sMach = ""
While .bMach(i) <> 0
sMach = sMach & Chr(.bMach(i))
i = i + 1
Wend
i = 1
sUser = ""
While .bUser(i) <> 0
sUser = sUser & Chr(.bUser(i))
i = i + 1
Wend
End With
sLogStr = sMach & " -- " & sUser
If InStr(sLogins, sLogStr) = 0 Then
sLogins = sLogins & sLogStr & ";"
End If
iStart = iStart + 64 '>increment to next record offset
Loop
Close iLDBFile
WhosOn = sLogins

Exit_WhosOn:
Exit Function
Err_WhosOn:
If Err = 68 Then
MsgBox "Couldn't populate the list", 48, "No LDB File"
Else
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
Close iLDBFile
End If
Resume Exit_WhosOn
End Function

'CODE END

Nov 12 '05 #2
Private Type UserRec
bMach(1 To 32) As Byte '>1st 32 bytes hold machine name
bUser(1 To 32) As Byte '>2nd 32 bytes hold user name
End Type
"John Peterson" <jt****@virginia.edu> wrote in message news:<bo**********@murdoch.acc.Virginia.EDU>...
Lauren -

Tried the code for fun, but get an error on

Dim rUser As UserRec

Where is type UserRec defined?

- jtp

"Lauren Quantrell" <la*************@hotmail.com> wrote in message
news:47**************************@posting.google.c om...
In my MS Access2000 MDB Files I used the code below to populate a list
box of all logged on users. Can anyone help me figure out a way to
modify the code to do the same with my MS Access2000 ADP Project.
Any help is appreciated.
lq

'CODE START

Function WhosOn() As String
On Error GoTo Err_WhosOn
'reads *.LDB file and read who is currently logged on and their
station name - the LDB file has a 64 byte record

Dim iLDBFile As Integer, iStart As Integer
Dim iLOF As Integer, i As Integer
Dim sPath As String, X As String
Dim sLogStr As String, sLogins As String
Dim sMach As String, sUser As String
Dim rUser As UserRec
Dim td As TableDef
Dim dbcurrent As dao.Database

Set dbcurrent = DBEngine.Workspaces(0).Databases(0)
'use this for current database:
'*sPath = dbCurrent.Name

'use this for networked database:
For Each td In dbcurrent.TableDefs
If Len(td.Connect) > 0 Then 'is a linked table
On Error Resume Next
sPath = right(td.Connect, Len(td.Connect) - 10) 'check
file name
On Error GoTo Err_WhosOn
GoTo nextstep:
End If
Next 'loop to next tabledef
GoTo nextstep:
nextstep:
dbcurrent.Close

'iterate thru dbCurrent.LDB file for login names.

sPath = Left$(sPath, InStr(1, sPath, ".")) + "LDB"

'test for valid file, else Error

X = Dir(sPath)
iStart = 1
iLDBFile = FreeFile

Open sPath For Binary Access Read Shared As iLDBFile
iLOF = LOF(iLDBFile)
Do While Not EOF(iLDBFile)
Get iLDBFile, , rUser
With rUser
i = 1
sMach = ""
While .bMach(i) <> 0
sMach = sMach & Chr(.bMach(i))
i = i + 1
Wend
i = 1
sUser = ""
While .bUser(i) <> 0
sUser = sUser & Chr(.bUser(i))
i = i + 1
Wend
End With
sLogStr = sMach & " -- " & sUser
If InStr(sLogins, sLogStr) = 0 Then
sLogins = sLogins & sLogStr & ";"
End If
iStart = iStart + 64 '>increment to next record offset
Loop
Close iLDBFile
WhosOn = sLogins

Exit_WhosOn:
Exit Function
Err_WhosOn:
If Err = 68 Then
MsgBox "Couldn't populate the list", 48, "No LDB File"
Else
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
Close iLDBFile
End If
Resume Exit_WhosOn
End Function

'CODE END

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marcin Zmyslowski | last post by:
Hello all! I want to create a page in ASP language which gives me information about currently logged users. I thought to do it by this way: when somebody will log in to page, there will be a...
8
by: Mike Thomas | last post by:
I have two clients now who want to have an Access 2000 & 2002 application running on NT Server 2000 do some file updating at night when nobody is in the office. I have used Windows scheduler to...
1
by: Gaurav | last post by:
Hi, is there a way to know which user last logged in the shared Access database. My requirement is that I must be able to track the users that log in the database and incase its not working...
6
by: John Dalberg | last post by:
I want to automate the process of logging into an intranet. I want to pull out the username of the Windows user logged into the machine running the browser and use the username in my app. How can I...
1
by: John | last post by:
Hi We can get the current logged in user's name but is it also possible to get the default email form outlook of the currently logged-in user as well? The reason for this is that I need to email...
15
by: Mephisto187 | last post by:
How can I find the currently visible desktop? By calling EnumWindowStations and EnumDesktops I get a list of all available desktops. But is there a way to figure out which one of them is currently...
6
by: MuZZy | last post by:
Hi, I am looking to find a way to get currently logged in user's object GUID without querying ActiveDirectory. For example, when i log in to my laptop from home, I'm not on the office network so...
2
by: gihope | last post by:
Hi, can anyone advise me how I can access the UserName of a currently logged in user without using the LoginName control. For instance I want to search tables I have created in my database that I...
5
by: Benedictum | last post by:
I need to implement an option to display on the web page for users currently logged in. How do I implement this in ASP.NET (c#). I could probably have a boolean field in the database where a user...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.