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 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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
|
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...
| |