Results 1 to 4 of 4
  1. #1
    andyt_2005 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    12

    Form to search for data by date range

    Hi guys,

    I have an issue i think can be solved by giving the user a form to select a date range from (from date to date) and produce a report with the outcome.
    However i have absolutely no idea how to even attempt this!


    Any ideas or help from the masters out there?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Options:

    1. dynamic parameterized query as the report RecordSource:
    SELECT * FROM tableORquery WHERE DateField BETWEEN Nz([Forms]![formname]![starttextbox], #1/1/1900#) AND Nz([Forms]![formname]![endtextbox], #12/31/2900#);

    2. code to build filter criteria and pass to report in OpenReport argument - VBA example:
    DoCmd.OpenReport "report name", , , strCriteria
    Review http://www.allenbrowne.com/ser-62code.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    J7's advice is correct, but perhaps a little intimidating for the novice. Essentially what you do is put the text boxes in your form - let's call them StartDate and EndDate in MyForm (don't use the word Date - it is reserved)....

    Then in the query that is the record source for the report (or if the report is sourced directly on a table you must first make a query) - here you add your 'call' as your query criteria from the form:
    Forms!MyForm.StartDate is the syntax

    If you are dealing with a single date column/field then probably: >=Forms!MyForm.StartDate AND <=Forms!MyForm.EndDate

  4. #4
    andyt_2005 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    12
    Guys Thank you ! managed to get it workign will both your help! Now onto my next issue .. . fun and games

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

Similar Threads

  1. Replies: 3
    Last Post: 09-11-2013, 09:49 AM
  2. Replies: 2
    Last Post: 12-16-2012, 01:40 AM
  3. Search Date Range with Null Sources
    By MintChipMadness in forum Forms
    Replies: 8
    Last Post: 08-23-2012, 08:56 AM
  4. Replies: 4
    Last Post: 05-26-2012, 09:29 AM
  5. Search form with a date range
    By mantro174 in forum Forms
    Replies: 1
    Last Post: 02-11-2009, 10:45 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