Results 1 to 5 of 5
  1. #1
    joeshig is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Location
    Warwickshire
    Posts
    4

    Combining two queries

    Hi, new to Access and SQL writing so bear with me.



    I have two queries on an Access form which check whether a car is covered by the manufacture warranty or not based on mileage and date of purchase.

    I have these as two separate text boxes on the form but struggling to combine these into one text box/query.

    Here are the queries:

    =IIf(DateDiff("yyyy",Date(),[txtPurchaseDate])>-"3","Covered")
    =IIf([txtMileage]<70000,"Covered")

    I've looked up and tried combining them by removing second = sign, sticking in AND/OR's but not sure if its as simple as that.

    Sorry if this is simple but appreciate the help.

    Cheers

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    A bit of nomenclature - these aren't queries, they are calculations in the Control Source of your Text Box.
    To combine both those checks into one, if would look like:
    Code:
    =IIf((DateDiff("yyyy",Date(),[txtPurchaseDate])>-"3") Or ([txtMileage]<70000),"Covered","")

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    DateDiff produces a numeric value, not a string.
    ...)>-3,"Covered"...

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    DateDiff produces a numeric value, not a string.
    ...)>-3,"Covered"...
    Good catch!

  5. #5
    joeshig is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Location
    Warwickshire
    Posts
    4
    Cheers guys! Will action this and take a look at the DateDiff. Appreciate your help

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

Similar Threads

  1. Combining Queries?
    By Khermann in forum Queries
    Replies: 1
    Last Post: 06-02-2016, 08:34 AM
  2. Help with Combining Queries
    By racefan91 in forum Queries
    Replies: 13
    Last Post: 10-07-2013, 02:42 PM
  3. Combining queries
    By jamo in forum Queries
    Replies: 11
    Last Post: 11-09-2012, 07:36 AM
  4. Combining two queries
    By Adele in forum Queries
    Replies: 1
    Last Post: 07-16-2011, 12:17 AM
  5. Combining Two Queries
    By csolomon in forum Queries
    Replies: 1
    Last Post: 09-03-2009, 01:33 PM

Tags for this Thread

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