Combo Search pulling incorrect field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • John Torres
    New Member
    • Jan 2008
    • 42

    #1

    Combo Search pulling incorrect field

    I am trying to create a combo box search on the form with the Part Number but for some reason it’s pulling the Part Number Table’s Primary Key. Can’t figure out why. Any ideas where to start?

    FYI- it's a look up field from a table. I'm trying to research how to fix it because I already invested a lot of time.

    Thanks,
    JT
  • Megalog
    Recognized Expert Contributor
    • Sep 2007
    • 378

    #2
    Can you post the code you're using for your search? Specifically the part where it calls on the combo box itself. Also, post the sql you're using for the combo's rowsource. You are probably bound to that table's primary key, but on the combo control, you're displaying a different field. So the combo's .Value property is going to be the selected index number of the table.

    So the value you visually select (the unbound data), may not be the value that's being passed to your search function.

    If this is the case, you can try using the column feature to get the currently selected unbound data.

    me.cboObject.Co lumn([Column # starting with 0],[Row #])

    In this example, the first number (1) is the second column #, and the Listindex property provides the currently selected row #.

    me.cboObject.Co lumn(1, me.cboObject.Li stIndex)

    There might be a property that just returns what the selected visible text is, but I cant remember what it is offhand.

    Comment

    • John Torres
      New Member
      • Jan 2008
      • 42

      #3
      Here's the Code:
      Code:
      SELECT [Material Inventory].[Material Inventory ID], [Material Inventory].[Part Number] FROM [Material Inventory];
      Thanks again!
      John

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        John, you need to look, not at the code so much, as the properties of your ComboBox control. Specifically Column Count, Column Heads and Bound Column. I suspect your Bound Column is set to 2 rather than 1, but read up in the Help system to see what they mean and do.

        PS. Please remember to use CODE tags when posting code in future.

        Comment

        Working...