Results 1 to 4 of 4
  1. #1
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142

    Query based on the date selection

    I need a query to pull data from 2 tables depending on the selection of the date.


    If the date is selected from the previous 2 weeks, data should be extracted from one table and if the data is selected from the current and next week , it should get extracted from the other table.

    Can anyone help me with this.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Why is the data in two tables? What if the data requested overlaps the tables? It should probably be in one table. A UNION query would be a workaround.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    In the form, see what range is in the text boxes, then open that query:
    Code:
    if date() >= txtStart and date()<= txtEndDate then
        Docmd.openQuery "qsCurrent"
    else
       Docmd.openQuery "qsPrevious"
    endif

  4. #4
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    I have a problem here.
    How do I implement this in the combo box?[

    QUOTE=ranman256;406305]In the form, see what range is in the text boxes, then open that query:
    Code:
    if date() >= txtStart and date()<= txtEndDate then
        Docmd.openQuery "qsCurrent"
    else
       Docmd.openQuery "qsPrevious"
    endif
    [/QUOTE]

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

Similar Threads

  1. Replies: 2
    Last Post: 08-22-2014, 01:20 PM
  2. Re-query Field Based On Selection
    By mes5464 in forum SharePoint
    Replies: 1
    Last Post: 08-08-2013, 10:03 AM
  3. Replies: 4
    Last Post: 02-09-2012, 03:03 AM
  4. Query based on ComboBox selection
    By pmac in forum Queries
    Replies: 9
    Last Post: 07-27-2011, 07:03 AM
  5. run parameter query based on option box selection
    By rivereridanus in forum Queries
    Replies: 1
    Last Post: 07-01-2011, 01:07 PM

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