DLookup & ComboBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kcludick
    New Member
    • Sep 2015
    • 3

    DLookup & ComboBox

    Hi, I have a table called Tbl_ComboBox, and a form named Form1. On the form I have a combobox where you select an employee code. I need to do a DLookUp from an Unbound text box to auto fill the Name of person that is equal to my selected Combobox value. This is what I have:

    =DLookUp("[Name]","[Tbl_ComboBox]","[Employee Code].[Tbl_ComboBox]= " & [Combo2].[Text]). Not working. What am I missing? Please help
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    Try changing it to
    Code:
    =DLookUp("[Name]","[Tbl_ComboBox]","[Employee Code]= " & Forms!Your_Form_Name![Combo2])
    If Employee code is a text field, then it would need to be like this:
    Code:
    =DLookUp("[Name]","[Tbl_ComboBox]","[Employee Code]= '" & Forms!Your_Form_Name![Combo2] & "'")

    Comment

    • hvsummer
      New Member
      • Aug 2015
      • 215

      #3
      As Seth said, you miss the ' out side text field condition.
      beside that, if you want to call out value of combo box, you should use me!combobox as condition for looking field.

      but I suggest you create combobox with rowsource
      Code:
      SELECT EmployeeCode, EmployeeName from Tbl_ComboBox
      then set combobox column count property to 2, bound column to 1
      then set text box control source like this
      Code:
      =comboboxEmployeeCode.column(1)
      you'll have problem resolved.

      Comment

      • kcludick
        New Member
        • Sep 2015
        • 3

        #4
        Thank you Seth and hvsummer....It is working perfectly now!!!!

        Comment

        Working...