Results 1 to 4 of 4
  1. #1
    Yewee is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    9

    How can i combine the below query

    Hi All,

    I have a query named "QueryPriorityStaticsByNoOfDay" and a Form named FormDateRange. Inside the Form, there is a Frame with 3 options. Option 19, option 21 and option 23.
    The value for Option 19 = 1, Option 21 = 2, Option 23 = 3
    When user select option 19, it should run query with NofoDay<=1, Option 21 should run with NoofDay =2 or 3 and Option 23 = more than 3 days.


    Field name :



    Option 19:

    Select * from QueryPriorityStaticsByNoOfDay
    Where NoOfday<=1
    Group by Priority

    Option 21:

    Select * from QueryPriorityStaticsByNoOfDay
    Where NoOfday= 2 or 3
    Group by Priority

    Option 23:

    Select * from QueryPriorityStaticsByNoOfDay
    Where NoOfday>=3
    Group by Priority


    Anyone can give idea how to do it?

    Thanks.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    something like

    Code:
    Select * from QueryPriorityStaticsByNoOfDay
     WHERE (forms!myform!myFrame=1 And [NoOfday]<=1) OR (forms!myform!myFrame=2 And [NoOfday] between 2 and 3) OR (forms!myform!myFrame=3 And [NoOfday]>=3)
    Group by Priority

  3. #3
    Yewee is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    9
    Hi hi,

    Thanks.
    Can I check, I have the Form that let the user generate the report according to their selection.
    For example, they will select either 'less than a day, '2 to 3 days' and 'more than 3 days'.
    Once they select, the report will only generate according to that selection.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    really depends on how you are running the report - you could put the where part of the query as a parameter to docmd.openreport for example - in which case you would build a string to suit based on the value of your frame.

    Please don't ask a question and then move the goalposts, will it work here? will it work there? Try it and see

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

Similar Threads

  1. Query to combine(?) records
    By MikeNZ in forum Queries
    Replies: 5
    Last Post: 07-27-2016, 07:47 AM
  2. To combine and sum in a query
    By mdnikki in forum Queries
    Replies: 7
    Last Post: 11-08-2012, 12:50 PM
  3. Combine Two Fields in a Query?
    By Luke in forum Access
    Replies: 1
    Last Post: 07-28-2011, 10:00 AM
  4. combine query result
    By Fenvy in forum Queries
    Replies: 1
    Last Post: 06-22-2011, 05:02 PM
  5. combine three tables in a query
    By neuenglander in forum Queries
    Replies: 0
    Last Post: 08-21-2008, 04:02 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