+ Reply to Thread
Results 1 to 3 of 3

Populate List Box from Text box

  1. #1
    Registered User
    Join Date
    07-25-2018
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    1

    Populate List Box from Text box

    Hi
    I have two tables :
    1. Employee : EmployeeID, EmployeeName ..
    2. Project: ProjectID, EmployeeID, ProjectName, ElementName , WBS

    TextBox (EmployeeID) : displays employee ID (Populates from another list Box selection)
    List Box (ListProject) : displays ProjectName, ElementName, WBS

    Once the EmployeeID populated from another list Box
    I want the ListProject should populate the list of projects associated with that employee ID.

    Could you please help me with this.
    I tried placing this query in the after update function in the text box:
    Private Sub EmployeeID_AfterUpdate()
    Dim SQL As String
    SQL = "Select ElementName,ProjectName,WBS From[Project] where [EmployeeID] = " & Me![EmployeeID].Value
    Me![ListProject].RowSource = SQL
    Me![ListProject].Requery
    End Sub

    And added the rowsource of the List box as this :
    to the employee ID: In criteria:

    [Forms]![formname]![EmployeeID]


    But the values are not populating.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Populate List Box from Text box

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    08-23-2018
    Location
    Ireland
    MS-Off Ver
    Office365
    Posts
    17

    Re: Populate List Box from Text box

    Your sub is setting the row source of the list box, so you do not need the criteria:

    Please Login or Register  to view this content.
    I would remove that completely

    Also, check that the SQL statement works on its own in the query window. Ensure that if you substitute an employee id that you know has associated projects, that the query actually returns rows

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Text box to populate based on drop-down list cell value while sheet is "protected".
    By rxharp419 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-30-2017, 06:40 PM
  2. [SOLVED] Populate userform text boxes with dater from another sheet, dependant on list box selectio
    By MallorcaPete in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-17-2015, 07:01 AM
  3. Replies: 7
    Last Post: 05-04-2015, 04:01 AM
  4. [SOLVED] How to auto populate multiple Text Boxes from list based on value of a cell
    By MooseAUH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2014, 03:40 AM
  5. Replies: 1
    Last Post: 11-05-2013, 12:40 AM
  6. [SOLVED] When drop down is selected I want text from another list to populate different cell
    By slowride in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-27-2013, 01:17 AM
  7. Replies: 3
    Last Post: 02-28-2012, 11:54 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1