Results 1 to 4 of 4
  1. #1
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42

    Set value of combobox from variable

    Hello all.

    I have a combobox that allows users to select users from the sys_Users table. The combobox had a record source that combines the UserID of the user with their First and Last names from the Employees table.

    When users login, their UserID is stored to a TempVars variable, and I just want to set the intial value of that combo box to the TempVars!UserID, but things like: Me.UserID.Value = TempVars!UserID don't work. Does anyone know how to do this?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you can get the userID from their login:

    cboBox = Environ("Username")

  3. #3
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42
    Quote Originally Posted by ranman256 View Post
    you can get the userID from their login:

    cboBox = Environ("Username")
    The only thing is that I don't want to use their Windows username, as some of our computers are shared with universal user accounts. So I want to populate the combo box from the users table in the database. I'll try cbobox = TempVars!UserID though

  4. #4
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42
    Quote Originally Posted by ranman256 View Post
    you can get the userID from their login:

    cboBox = Environ("Username")
    That worked! Thank you! I guess I was trying to over-complicate the process thinking I had to include .Value or .Selected . . .

    Thank youi!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error 91 Object Variable or Block Variable Not Set
    By mindbender in forum Programming
    Replies: 5
    Last Post: 05-01-2017, 12:01 PM
  2. Replies: 3
    Last Post: 05-28-2013, 12:53 PM
  3. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  4. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  5. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums