Re: Help with code
- From: Sam <Sam@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 15 Sep 2005 16:19:03 -0700
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???
"'69 Camaro" wrote:
> 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.
>
>
> "Roger Carlson" wrote:
>
> > 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
> > 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 sLogStr <> " -- " And InStr(sLogins, sLogStr) = 0 Then
> > sLogins = sLogins & sLogStr & ";"
> > End If
> > iStart = iStart + 64 'increment to next record offset
> > Loop
> > Close iLDBFile
> >
> > Exit_GetUserList:
> > GetUserList = sLogins
> > Exit Function
> >
> > Err_GetUserList:
> > 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_GetUserList
> >
> > End Function
> > '*************************************************
> > "Sam" <Sam@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > news:3ECA397C-482A-461C-ABB7-EBDE17F41FFD@xxxxxxxxxxxxxxxx
> > > Hello
> > >
> > > I have downloaded a form that shows who is logged on, however it only
> > shows
> > > one person as being logged on (me) when I know that several other people
> > are
> > > also logged on.. The code attached to the form is as below:--
> > >
> > >
> > > Option Compare Database 'Use database order for string comparisons
> > > Private Sub Form_Open(Cancel As Integer)
> > > Me.LoggedOn.RowSource = WhosOn()
> > > End Sub
> > >
> > > Private Sub OKBtn_Click()
> > > DoCmd.Close A_FORM, "LoggedOn"
> > > End Sub
> > >
> > > Private Sub UpdateBtn_Click()
> > > Me.LoggedOn.RowSource = WhosOn()
> > > End Sub
> > >
> > > Is there a way to make this list everyone within the data base, or does
> > > anyone have a good program/ form that does this ???
> >
> >
> >
.
- Follow-Ups:
- Re: Help with code
- From: '69 Camaro
- Re: Help with code
- References:
- Re: Help with code
- From: Roger Carlson
- Re: Help with code
- Prev by Date: RE: Timer updated on form
- Next by Date: Re: Setting a Recordsetclone with DAO
- Previous by thread: Re: Help with code
- Next by thread: Re: Help with code
- Index(es):
Relevant Pages
|