So If I create a "Dummy" table on the FE & BE and bind the main menu to
this
table, would this work?
:
Hi, Sam.
If I am in the main menu, then the LDB viewer shows me as not being
logged
in. If I choose the main data entry form, then it show me as being
logged in.
Why is this happening???
The LDB Viewer has a limitation, too. It can only monitor one
database
file
at a time. If the LDB Viewer is monitoring the back end and your main
menu
is not bound to a table linked to the back end, then you won't have
the
back
end database file open. If the main data entry form is bound to a
linked
table, the LDB Viewer will show you as being logged into the back end.
If you need to monitor multiple database files, it would probably be
best
to
use the code in the KB article to display the "logged in" information.
But
you can also use the LDB Viewer to bounce back and forth between two
database
files. Just keep in mind that you can only view the information for
one
file
at a time.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a
message
will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the
question
"Did this post answer your question?" at the bottom of the message,
which
adds your question and the answers to the database of answers.
Remember
that
questions answered the quickest are often from those who have a
history
of
rewarding the contributors who have taken the time to answer questions
correctly.
:
I have been using the LDB viewer but I seem to get a problem with it
recording who is on. I have set up menus on the data base (I am not
using the
switchboard as it is too restrictive)
If I am in the main menu, then the LDB viewer shows me as not being
logged
in. If I choose the main data entry form, then it show me as being
logged in.
Why is this happening???
:
Hi, Roger.
The WhosOn() code was originally created by Mark Nally for
Access
2.0
Thanks for that information.
but
it is still perfectly valid (even though it is ancient).
It has one major shortcoming. It reads the LDB file, not the list
of
current users actually logged on. Since no record is ever deleted
from the
LDB file, it shows the list of users currently logged in, as well
as
all
users whose entry in the file has not yet been overwritten by a
new
user.
For example, if five concurrent users opened the database, then
four
of them
exited, then a new user opened the database, the LDB file would
show
the
first two users that are currently using the database, as well as
three of
the previously users who have already exited the database. Not a
very
accurate list.
On the other hand, the LDB Viewer shows all current users, and the
KB
article I referenced in my post uses the user roster of all users
currently
logged into the database.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a
message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the
question
"Did this post answer your question?" at the bottom of the
message,
which
adds your question and the answers to the database of answers.
Remember that
questions answered the quickest are often from those who have a
history of
rewarding the contributors who have taken the time to answer
questions
correctly.
:
The WhosOn() code was originally created by Mark Nally for
Access
2.0, but
it is still perfectly valid (even though it is ancient). The
problem is you
are looking at the LDB file for the front end, rather than for
the
back end
database. To view the LDB file for the back end, you have to
supply the
database name of a linked table.
The offending section of code is this:
Set dbCurrent = DBEngine.Workspaces(0).Databases(0)
sUserList = ""
vTempList = GetUserList(dbCurrent.Name, sUserList)
You need to send the file name (with the entire path) to the
GetUserList
function.
One way to do this is with ADO:
'********************************
Function FindSource() As String
'this function finds the Connect string of the first
'linked table in the hidden 'MSysObjects' table. It then
'returns just the path & filename. Note: this assumes all
'of the linked tables are in the same file. If this is not
'true, you can replace the DFirst function with the name of
'a specific linked table.
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
Dim strLinkedTable As String
cat.ActiveConnection = CurrentProject.Connection
Dim txtLinkedTable As String
txtLinkedTable = DFirst("Name", "MSysObjects", "[Type] = 6")
'MsgBox txtLinkedTable
Set tbl = cat.Tables(txtLinkedTable)
'MsgBox tbl.Properties("jet OLEDB:Link Datasource")
FindSource = tbl.Properties("jet OLEDB:Link Datasource")
End Function
'********************************
Then you can supply the back-end database file name like this:
vTempList = GetUserList(FindSource(), sUserList)
Note: for reference the WhosOn code is listed below:
'*************************************************
Option Compare Database
Option Explicit
'Originally written for Access 2 by Mark Nally
'Revised an updated for Access 97 by:
'
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
Private Sub Form_Open(Cancel As Integer)
Me.LoggedOn.RowSource = WhosOn()
End Sub
Private Sub OKBtn_Click()
DoCmd.Close A_FORM, "frmLoggedOn"
End Sub
Private Sub UpdateBtn_Click()
Me.LoggedOn.RowSource = WhosOn()
End Sub
'-----------------------------------------------------------------
' Subject : WhosOn()
' Purpose : Will read *.LDB file and read who's currently
' logged on and their station name.
'
' The LDB file has a 64 byte record.
'
' The station name starts at byte 1 and is null
' terminated.
'
' Log-in names start at the 33rd byte and are
' also null terminated.
'
' I had to change the way the file was accessed
' because the Input() function did not return
' nulls, so there was no way to see where the
' names ended.
'---------------------------------------------------------------------------
----------
Private Function WhosOn() As String
On Error GoTo Err_WhosOn
Dim dbCurrent As DAO.Database
Dim sUserList As String, vTempList As Variant
' Get Path of current database
' and for an attached table path in a multi-user environment.
Set dbCurrent = DBEngine.Workspaces(0).Databases(0)
sUserList = ""
vTempList = GetUserList(dbCurrent.Name, sUserList)
If Not IsNull(vTempList) Then
sUserList = vTempList
vTempList = GetUserList(Forms!frmCurrentPaths!Text2,
sUserList)
If Not IsNull(vTempList) Then sUserList = vTempList
End If
WhosOn = sUserList
dbCurrent.Close
Set dbCurrent = Nothing
Exit_WhosOn:
Exit Function
Err_WhosOn:
Resume Exit_WhosOn
End Function
Private Function GetUserList(sSourcePath As String,
sCurrentLogins)
As
Variant
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 ' Defined in General
On Error GoTo Err_GetUserList
GetUserList = Null
sPath = Left(sSourcePath, InStr(1, sSourcePath, ".")) +
"LDB"
' Test for valid file, else Error
x = Dir(sPath)
iStart = 1
sLogins = sCurrentLogins
iLDBFile = FreeFile
' Iterate thru LDB file for login names.
Open sPath For Binary Access Read Shared As iLDBFile