none
making a query from a combo box value RRS feed

  • Question

  • I have 2 queries, both of which use their own combo box for the value to query for. One query selects from a form field that only has integer values. This query works fine. The other query selects from the same form, but uses a field that has text values. The text value query fails if it is activated by a button on the form. However, if I run the query by itself, and Access prompts me for the value it would normally get from the combo box, the query works. Why would an interger-based query work, and a similar text-based query fail? Here is the SQL for the 2 queries:

    this works:

    SELECT pc_details_table.ID, pc_details_table.User, pc_details_table.ip_address
    FROM pc_details_table
    WHERE (((pc_details_table.ID)=[Forms]![Form1]![id_combo_value]));

    this fails:

    SELECT pc_details_table.ID, pc_details_table.User, pc_details_table.ip_address
    FROM pc_details_table
    WHERE (((pc_details_table.User)=[Forms]![Form1]![user_combo_value]));

    Monday, August 17, 2015 3:23 PM

Answers

  • Hi. Can you post the row source for the combobox? It's probably a matter of knowing what value the combobox is returning to the query, and that is dictated by the bound column. You could be looking at one thing on the combobox, but the query could be getting something else (a hidden column, for example). Basically, it's hard to expect two queries that filters on two different columns to get the same result when using the same filter/criteria value. Also, could you please elaborate on what you mean by the query "fails?" Are you just not getting any records back, or are you getting an actual error message? Thanks.
    Monday, August 17, 2015 3:50 PM