Results 1 to 3 of 3
  1. #1
    rajgoyal00 is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Posts
    26

    Please Help!!!! Having a headache trying to figure this out (Query Criteria)

    I have a database, with table Car_Parts_Tbl with fields:



    ID
    Make "Text"
    Series "Text"
    Model "Text"
    YearVal_From "Number" Not Date
    YearVal_To "Number Not Date
    Part "Text"
    Qty "Number"

    I have created a query(Car_Parts_Tbl Query) based on selections on a Form (Data_Entry_Form1)

    Query in based on the Car_Parts_Tbl and has all its field also except ID

    So far I have figured everything that I wanted to except: In the criteria field of the [YearVal_From] of the query.
    I have written

    Like IIf([Forms]![Data_Entry_Form1]![Year_From] Is Null,"*") Or >=[Forms]![Data_Entry_Form1]![Year_From]

    It shows me all the records if the (Year_From combo box of the form) is NULL, and it has a value, it shows all the records where the Year value is same or greater.

    But there is a problem. for Eg.
    If have a record

    MAKE MODEL YearVal_From YearVal_To Part Qty
    BMW E60 2004 2010 XX 2

    If the form has the value 2004, I see this record, and all of them above 2004.

    But If I choose 2005 It doesnt show me this record.

    Since 2005 falls in the records range of YearVal_From 2004 YearVal To 2010
    I want it to show.

    I have tried a few different things, like Between and Dmax... but nothing seems to be working, I am tired scratching my head!!!!!!!!!


    Please help.......

    I have attached a sample databaseSample DB.accdb
    Thanks

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Try "BETWEEN". Like this

    WHERE (((Car_Parts_Tbl.YearVal_From) Like IIf([Forms]![Data_Entry_Form1]![Year_From] Is Null,"*"))) OR (([Forms]![Data_Entry_Form1]![Year_From] Between [Car_Parts_Tbl].[YearVal_From] And [Car_Parts_Tbl].[YearVal_To]));

  3. #3
    rajgoyal00 is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Posts
    26
    I can not thank you enough!!!!!!!!!!!!

    It WORKED!!!!!!!!!!!!
    Seems like magic

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Can't figure out Access query
    By luderbeck1 in forum Queries
    Replies: 3
    Last Post: 02-02-2012, 12:12 PM
  2. Query Criteria causing a headache
    By GavinBlackburn in forum Queries
    Replies: 2
    Last Post: 07-12-2011, 04:55 AM
  3. Need a query to figure all possible combinations
    By julestrip in forum Queries
    Replies: 1
    Last Post: 05-27-2011, 07:23 AM
  4. Cannot Figure this query out
    By ryan1313 in forum Queries
    Replies: 6
    Last Post: 08-13-2010, 12:54 PM
  5. Huge Query Headache
    By Gary in forum Access
    Replies: 1
    Last Post: 08-09-2010, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums