Using combo box to submit criteria to query?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • scottbouley
    New Member
    • Sep 2008
    • 30

    Using combo box to submit criteria to query?

    I have a query that queries the work order table by date. I want to be able to query by last 30, 60, or 90 days.

    I'm using a combo box on my main form to select 30, 60 or 90 days. The bound column for the combo box should return
    Code:
    >= Date()-30
    Code:
     >= Date()-60
    or
    Code:
    >= Date()-90
    depending on which one is selected.

    I have the following code for the after update event for the combo box:

    Code:
    Forms![frm_Main].[sfrm_WO_Query_Results].Form.Requery
    When I open the form I get the following error:

    "the expression is typed incorrectly or it is too complex to be evaluated..."

    If I type the criteria directly into the query it works fine.

    I tried eliminating the combo box as a part of the problem by closing the form and entering the criteria at runtime. However, I get the same error.

    Access seems to have a problem receiving criteria in the form of an expression from a comba box.

    Is this possible and I'm just missing something?

    Thanks in advance.
  • scottbouley
    New Member
    • Sep 2008
    • 30

    #2
    Problem solved. I changed the query criteria to >=Date()-[Forms]![frm_Main]![cbo_Date_Range] and pulled the number of days instead of the entire expression.

    Comment

    Working...