Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    People on the network (97)

    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

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: People on the network (97)

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

  3. #3
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: People on the network (97)

    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

  4. #4
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: People on the network (97)

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

  5. #5
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: People on the network (97)

    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.

  6. #6
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: People on the network (97)

    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 <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

  7. #7
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: People on the network (97)

    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:
    <pre>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</pre>


    Now, I actually haven't tested this code, but it should be a good jumping off point.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •