Results 1 to 10 of 10
  1. #1
    Star Lounger
    Join Date
    Jul 2007
    Location
    North Carolina, USA
    Posts
    71
    Thanks
    5
    Thanked 0 Times in 0 Posts

    DB Users in Combo Box (2003)

    I have multiple users who log in to the database I am creating.
    Each User has there own login.
    I want to use the user logins in a drop down list so they can be assigned to records in the database by the Admin User.

    I understand how to use CurrentUser() to populate a field in my table, but I am trying to create a drop down with all the Users.
    Can someone please point me in the right direction, any help is greatly appreciated.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DB Users in Combo Box (2003)

    From your description, I assume that you applied user-level security to the database. If so, you know which users you have created, so you can create a table with the login names. You can use this table as row source for the combo box (dropdown list).

  3. #3
    Star Lounger
    Join Date
    Jul 2007
    Location
    North Carolina, USA
    Posts
    71
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: DB Users in Combo Box (2003)

    Yes, I do know who they are. I was just hoping there was a way that it would pull the list so I could minimize the number of tables that would require updates when the User's changed.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DB Users in Combo Box (2003)

    You could use a combo box with its RowSourceType property set to "Value List", and set its Row Source in code when the form is opened:

    Private Sub Form_Open(Cancel As Integer)
    Me.cboUsers.RowSource = ListUsersInSystem
    End Sub

    The ListUsersInSystem function could be placed in a standard module:

    Function ListUsersInSystem() As String
    Dim ws As Workspace
    Dim i As Integer
    Dim strRet As String

    Set ws = DBEngine.Workspaces(0)
    For i = 0 To ws.Users.Count - 1
    strRet = ";" & ws.Users(i).Name & strRet
    Next i
    ListUsersInSystem = Mid(strRet, 2)
    End Function

    (This function requires a reference to the Microsoft DAO 3.6 Object Library; it is based on code provided by Microsoft in its Security FAQ)

  5. #5
    Star Lounger
    Join Date
    Jul 2007
    Location
    North Carolina, USA
    Posts
    71
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: DB Users in Combo Box (2003)

    Hans,

    Thank you so much for your help. I think I am missing something in the instructions. I tried doing this in a blank form and it either errors out or it creates an empty combo box. If you are able to provide additional help I would appreciate it. Thanks.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DB Users in Combo Box (2003)

    What happens if you
    - Activate the Visual Basic Editor,
    - Press Ctrl+G to activate the Immediate window,
    - Type ? ListUsersInSystem and press Enter?

  7. #7
    Star Lounger
    Join Date
    Jul 2007
    Location
    North Carolina, USA
    Posts
    71
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: DB Users in Combo Box (2003)

    Hans,
    I did what you said and it does pull the list of users I am wanting. Can you give me a little help with how to use this, or is ListUsersInSystem all I need?

    Thank you so much for your help.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DB Users in Combo Box (2003)

    Did you set the Row Source Type property of the combo box to Value List?

  9. #9
    Star Lounger
    Join Date
    Jul 2007
    Location
    North Carolina, USA
    Posts
    71
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: DB Users in Combo Box (2003)

    Hans, I did set it to Value List. I tried this last night when I was finally able to get woody's to open. Let me try it again and I will see if maybe I just made a typo. Thanks so much for your patients.

    Okay, I was able to try it again, I cannot seem to figure this one out. I know I am missing something you probably already gave me. I cannot seem to get a Row Source Code that actually makes it show in my combo box.

    I would really like to be able to use this list for the lookup in a table, even if through the form. Thanks for being patient as I learn what you are sending me.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DB Users in Combo Box (2003)

    Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

Posting Permissions

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