Re: Help with code

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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 ???
> >
> >
> >
.



Relevant Pages

  • RE: Combo Box on User Form
    ... 'declare variables for new connection and recordset and declare variables ... Dim vConnection As New ADODB.Connection ... Dim vClientFName As String ... MsgBox "The connection to this database is working!", ...
    (microsoft.public.word.vba.general)
  • Re: running fRefreshLinks from another database
    ... lock the database I want to update links in. ... Dim i As Integer, strDBPath As String, strTbl As String ... Dim dbCurr As Database, dbLink As Database ...
    (microsoft.public.access.modulesdaovba)
  • Re: Combo Box on User Form
    ... 'declare variables for new connection and recordset and declare variables ... Dim vConnection As New ADODB.Connection ... Dim vClientFName As String ... MsgBox "The connection to this database is working!", ...
    (microsoft.public.word.vba.general)
  • Re: Changing the background color and re-linking the backend when
    ... Essentially what I needed was to replace every reference to tblMember to be replaced to tblMemberUS in one Access database and to tblMemberNU in another Access database. ... Dim strDbName As String ... Function RefreshLinksBeSef() As Boolean ...
    (microsoft.public.access.formscoding)
  • Re: A VB 6 program to read from and save to text file
    ... I wrote a small program which for you, which imports the data from your text file into a database and displays them in a DBGrid. ... Const OldFile As String = "Datafile.txt.old" ... Dim MyData As String ... Kill MyPath & OldFile ...
    (microsoft.public.vb.winapi)