• People on the network (97)

    Author
    Topic
    #376070

    I’ve been experimenting with the .visible property. I have managed to make a combo box appear when i click on a certain area of a form. (A transparent button)

    however, i’m thinking this could be taken further using the identity of the person logged on. (Security is set on this database, im just doing some project work within it).

    sooooo,,,,,,,,
    lets say i create a table of people who i want certain menu’s to appear..

    Bob
    Jeff
    Phil

    And i have some way of seeing who is actually logged in.. lets call him/her ‘User’

    Can anyone come up with a small piece of code to check the table for me ?

    ——————————–

    I would imagine the code would go on the on open part of the form ?
    Sorm sort of loop with, If User = Table then
    Forms!Combobox1.Visible = True
    Forms!Combobox2.Visible = True
    in the middle ?

    Thereby giving extra functions to certain people.

    Regards

    Steve

    Viewing 1 reply thread
    Author
    Replies
    • #614628

      To see who is logged on you can read the LDB file.
      Have a look at ACC97: How to Read .LDB Files

    • #614632

      Set the controls property for the controls you are going to turn on and off to Visible = False

      In the OnCurrent event of your form

      If ([CurrentUser] = “Bob”) Or ([CurrentUser] = “Jeff”) Then
      Forms!Combobox1.Visible = True
      Forms!Combobox2.Visible = True
      End If

      [CurrentUser] holds the name of whoever logged in to the DB.

      When Phil logs in the controls are all ready set to Visible = False

      • #614651

        accdb is [Currentuser] a special word to denote who is using the database at the moment. or does it go further than that, and code is needed to determine [Currentuser] ?

        • #614656

          Yes. [Currentuser] is a special word to denote who is using the database at the moment. No, you don’t need any code to determine the [Currentuser].

          Search on CurrentUser Function in the help files to get a detailed explanation.

      • #614657

        Ahh checked visual basic help, [Currentuser] is who the user currently is.

        Does anyone know how to read the users from a table, instead of lots of OR statements ?

        Thanks for the help cool

        • #614669

          This is off the top of my head, and probably how I would approach it.
          Create a table (tblUserControls) with 3 fields
          fldUser – Text
          fldControl – text
          fldVisible – True/False

          In the Open event of the form:

          Private Sub Form_Open(Cancel As Integer)
           
          Dim strSQL as String
          Dim rst as Recordset
           
          strSQL = "SELECT * FROM tblUserControls WHERE fldUser = '" & [CurrentUser] &"'"
           
          Set rst = CurrentDB.OpenRecordset(strSQL)
           
          Do while not(rst.EOF)
              Me.Controls(rst!fldControl).Visible = rst!fldVisible
              rst.MoveNext
          Loop
           
          rst.close
          Set rst = Nothing
          
          End Sub

          Now, I actually haven’t tested this code, but it should be a good jumping off point.

    Viewing 1 reply thread
    Reply To: People on the network (97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: