How to query using criteria from two fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • celticmystyrose
    New Member
    • Jun 2010
    • 2

    How to query using criteria from two fields

    I am a beginner in access
    I was making a database for work. I need to make a query to bring out information from two separate data fields.
    My table is as such
    Surname; First name; Date1; time 1; (date defect was noticed);date 2 Time 2 (date defect was noticed);
    for example a defect can be found maybe on a specific date and time or between different times and dates. or between different times on the same date.

    My query should produce any defects on a specific date for example Date1 Time 1 Date2 Time 2
    24/12/09 12.30 4/1/10 15.00
    26/12/09 15.00
    22/12/09 16.00 6/1/10 09.00

    If my parameter is 26/12/09 all three rows must show in my query. is this possible? can someone please help me on how to do it. Thanks
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    Try this, turn the test around sort of backward. Select the desired date as a constant and then compare it to the two date fields. The sql will look like this
    Code:
    SELECT tblData.ID, tblData.dtmDate, tblData.dtmDate1, #4/2/2010# AS Expr1
    FROM tblData
    WHERE (((#4/2/2010#)=[dtmdate1] Or (#4/2/2010#)=[dtmdate2]));
    Make sense?

    Jim

    Comment

    • celticmystyrose
      New Member
      • Jun 2010
      • 2

      #3
      Yes it does
      Thanks a lot
      I was thinking along those lines last night but couldn't make it to make sense now I can see where I was going wrong
      Thanks again

      Comment

      Working...