Search Query doesn't work with combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amwkl4
    New Member
    • Mar 2015
    • 11

    Search Query doesn't work with combo box

    I have a search query set up to search whatever value is present in a combo box in my search form. I also have a text box that holds the same function as the combo box.

    When I enter a value in my text box the search query will return a list of records, however if I select the exact same value from the drop-down list of the combo box, the search query will not return any records.

    The list that makes up the combo box is from imported external data from an excel document could this be a factor in the issue?
    Thanks for taking your time to read this.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    amwkl4,

    You haven't shown us the queries you are using, so it is impossible to troubleshoot at this point.

    Also, the Text Box and Combo Boxes "could" have different values, depending on how you have established the RowSource for your Combo Box. Please provide the Query used to populate your Combo Box as well.

    Then, we can take a look and see what you have.

    Comment

    • Seth Schrock
      Recognized Expert Specialist
      • Dec 2010
      • 2965

      #3
      I would guess that the combo box is bound to a hidden field so you are really searching for the text that you think that you are. Look at the Row Source for the combo box. This will tell you what fields it is pulling. Then look at your Column Widths property. The width for each field in the row source is listed, separated by a semi-colon. If the first width is set to 0, then you won't see the first field in your row source and thus the value that you are selected isn't what is getting searched for in your form.

      Comment

      • amwkl4
        New Member
        • Mar 2015
        • 11

        #4
        Seth,

        I think you are right, the combo box has a hidden column for ID (Primary Key). Is there any way I can select only the keywords column and exclude the ID column?

        Comment

        • amwkl4
          New Member
          • Mar 2015
          • 11

          #5
          I got it working now, I just created another table with the keywords column as the primary key so there are no hidden fields. The search query is functioning properly.

          Comment

          • Seth Schrock
            Recognized Expert Specialist
            • Dec 2010
            • 2965

            #6
            You can change the Bound To property to make it be the keywords column instead of the ID column. So if you only have those two fields, then change the property to 2.

            Comment

            • twinnyfo
              Recognized Expert Moderator Specialist
              • Nov 2011
              • 3662

              #7
              You can also refer to the second column in the list by referring directly to it:

              Code:
              Me.cboComboBox.Column(1)
              However, if you are searching for the text instead of the index, I would guess that your database is not fully properly normalized. See this topic for details: Database Normalization.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32661

                #8
                Originally posted by TwinnyFo
                TwinnyFo:
                However, if you are searching for the text instead of the index, ...
                I would suggest you are far better off filtering based on the ID than you are on the text. Text is what humans would use but computers find the IDs so much easier and more reliable to work with.

                Comment

                Working...