Results 1 to 15 of 15
  1. #1
    impuce is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    5

    Match one column data with data in the second column

    I don't know if this can be done but I have a table with columns named Manager, Employee, EmpNum.

    In a form created from the table, I have a 2 dropboxes, Manager and Employee.

    How do I auto-populate a textbox with the EmpNum of the name chosen from the Employee dropbox?



    It would be the same as a Vlookup in Excel.
    Last edited by impuce; 03-22-2023 at 01:17 PM. Reason: Solved

  2. #2
    madpiet is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    143
    Quote Originally Posted by impuce View Post
    I don't know if this can be done but I have a table with columns named Manager, Employee, EmpNum.

    In a form created from the table, I have a 2 dropboxes, Manager and Employee.

    How do I auto-populate a textbox with the EmpNum of the name chosen from the Employee dropbox?

    It would be the same as a Vlookup in Excel.
    You have to add the EmpNum to the dropdown's rowsource. "SELECT Employee, EmpNum FROM SomeTable"... and then in the controlsource for the textbox, you'd refer to the combobox. =Me.cboEmployee.Column(0)

  3. #3
    impuce is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    5
    Hi,

    Did has you mentioned. Changed "SomeTable" to the table I'm getting data from.
    The textbox come up with an error #Name?

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    EmpNum would be column(1) in the suggested rowsource. Why do you need a textbox when you can display the num in the combo? Or do you need to see both on the form?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    madpiet is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    143
    Well, in fairness, you said you have "a table". I'm not psychic, so I didn't know the name of the table.

    Want a good answer? Ask a good question, including all the relevant details.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by madpiet View Post
    =Me.cboEmployee.Column(0)
    "Me" is invalid outside VBA, the reference would be:

    =cboEmployee.Column(0)

    More here:

    http://www.baldyweb.com/Autofill.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Good catch.
    Someone needs to take a chill pill?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by Micron View Post
    Someone needs to take a chill pill?
    I had a similar reaction.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    impuce is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    5
    Quote Originally Posted by Micron View Post
    EmpNum would be column(1) in the suggested rowsource. Why do you need a textbox when you can display the num in the combo? Or do you need to see both on the form?
    I changed the (0) to (1) as it was the second column I needed. Still getting the same error. I even remove the "Me.", still the same.
    The reason I don't display the num in the combo is because depending on what the first number is, it goes to different departments.

  10. #10
    impuce is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    5
    Quote Originally Posted by pbaldy View Post
    "Me" is invalid outside VBA, the reference would be:

    =cboEmployee.Column(0)

    More here:

    http://www.baldyweb.com/Autofill.htm
    Still getting the same error.

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Oh, and is cboEmployee the name of the combo box?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    The reason I don't display the num in the combo is because depending on what the first number is, it goes to different departments.
    Unfortunately that doesn't clarify anything for me. You can have as many columns in a combo list as you want, and retrieve any column value from the chosen list item. What you see is the 1st visible column. Putting a name or number in another control when you already have a control that contains it (or could) is a bit odd to me - unless as I mentioned, you need to display more than one column value at the same time on the form.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  14. #14
    impuce is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    5
    Quote Originally Posted by pbaldy View Post
    Oh, and is cboEmployee the name of the combo box?
    That worked!

    Thank you!

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by impuce View Post
    That worked!

    Thank you!
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 05-14-2020, 04:11 PM
  2. Replies: 4
    Last Post: 11-29-2017, 10:01 AM
  3. If data does not match in Column 1 Use Column 2
    By P3ndrag0n in forum Queries
    Replies: 2
    Last Post: 02-11-2016, 11:32 AM
  4. Query to find Partial Match of Column Data
    By rachmorr9 in forum Queries
    Replies: 2
    Last Post: 09-22-2015, 09:09 PM
  5. Replies: 1
    Last Post: 11-12-2013, 02:19 AM

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