Results 1 to 4 of 4
  1. #1
    JeffGeorge is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    111

    Passing A Date Range From Form To Report


    I have a form where a user enters a starting date and an ending date. The form also has a button to open a report after putting in these dates. However, I can't seem to get the right syntax for using that date range as the criteria for the Date field on the report (which would link to the Date field of the database). I imagine that this is fairly easy to, and I've probably done it before, but I'm just drawing a complete blank at the moment.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Could use a parameterized query.

    Or

    Use VBA to build the criteria string and pass to the report with WHERE CONDITION of OpenReport, like:

    DoCmd.OpenReport "report name", , , "[fieldname] BETWEEN #" & Nz(Me.Start, "1/1/2000") & "# AND #" & Nz(Me.End, "12/31/2900") & "#"
    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
    JeffGeorge is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    111
    I don't know anything about VBA so I guess I would have to use a parameterized query. Does the query have to include all of the fields I want to have on the report or just the date filter? Speaking of filters, is there a way to just add a filter to the report so that it only includes the dates that fall within the range on the form?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    There is macro equivalent for the OpenReport method.

    Query must include fields desired for the report. That's what the report RecordSource property is for. The RecordSource can be a table name, query name, or SQL statement.

    Report has Filter and FilterOnLoad properties.
    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.

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

Similar Threads

  1. How create a table for a date range report
    By jegupta in forum Programming
    Replies: 12
    Last Post: 01-30-2014, 12:33 PM
  2. Date Range Report
    By seth.murphine in forum Reports
    Replies: 3
    Last Post: 04-23-2012, 02:46 PM
  3. Date Range Report with Multiple Date Fields
    By StevenCV in forum Reports
    Replies: 13
    Last Post: 02-29-2012, 08:29 AM
  4. Getting a date range to show on a report
    By recon2011 in forum Reports
    Replies: 3
    Last Post: 01-10-2012, 01:27 PM
  5. Define a date range for a report - Help
    By Optimus_1 in forum Access
    Replies: 4
    Last Post: 06-02-2010, 04:50 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