Results 1 to 2 of 2
  1. #1
    trussell is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2021
    Posts
    5

    Issues Refreshing SubReports Using Command Button on Report

    Hi everyone,

    I am very new to access, so I apologize if this is a silly question.
    I have set up a report (which I will refer to as the master report) that contains 2 subreports. Both of these subreports obtain their data from the same query. This query is meant to be a filter based on a date range which can be set by the user.

    The Date range is determined by two fields ("Start Date" and "End Date") which exist in a separate form.

    My objective was to have the user enter the Master Report, and find that all the data available is displayed in the SubReports. The user can then click a command button in the header of the Master Report, which then opens up the Form that holds the "Start Date" and "End Date" fields. When the user selects a start date and an end date within that form, they are then returned to the Master Report. I want another button on the dashboard, which then refreshes the data for the SubReports, so that they will now only display the data that fits in that date range.

    I understand that a text filter could normally be used, but I want to eventually be able to implement more complex filters via the form, so this is the approach I want to take.

    The way I have approached this problem is to (1) write a macro, which runs upon entry into the Master Report, that sets the "Start Date" and "End Date" values to be a range that captures all the data within the database. (2) I have a command button which opens the form, and then sets the "Start Date" and "End Date" values to be whatever the user inputs.

    Here is the problem. Currently, if I am willing to have the user select all the subreports manually, and then hit refresh, it will work. However, I would like a single button in the Master Report which would refresh all the subreports automatically. I have tried a few different approaches to this, but I am honestly stumped. I cannot get it to work.

    If anyone can tell me what I need to write in order to automatically refresh the subreports from a command button within the Master Report, I would greatly appreciate that. Alternatively, if anyone has read my approach and sees where I have gone wrong, saying so would also be greatly appreciated! I would not be surprised if there is an easier way to do this, which I have missed due to my inexperience.

    Thanks!

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    9,171
    I've never taken this approach, figuring that reports aren't meant to be interactive. I'd have a report opening form and do all filtering from that point. One has to close the open report(s) and reopen them with the new filter/sort but it's pretty seamless. I imagine your issue is that you don't have the hierarchy correct in whatever you tried which would have given your post more clarity and us something to work with. Perhaps it should look something like

    Me.Child0.Report.Filter = "[FieldNameHere]= 'TextValueHere'"
    Me.Child0.Report.FilterOn = True

    If you are working with dates, then your subreport filter will be different but how are you getting those dates into the reports now? Forms! reference because the date form is still open? You pass them into report OpenArgs? They are fields on the main report too? Something else?
    I don't see a need for another button to refresh. Why not just use the button code on the main report that launches the date form?
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

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

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2016, 03:48 PM
  2. Command Button to Refresh Report
    By Elwood07 in forum Reports
    Replies: 1
    Last Post: 07-04-2015, 07:33 PM
  3. Command Button on Report
    By Hank153 in forum Reports
    Replies: 9
    Last Post: 10-27-2013, 07:54 PM
  4. Command Button Hover Issues
    By JeffG3209 in forum Database Design
    Replies: 6
    Last Post: 08-10-2011, 05:17 AM
  5. Replies: 1
    Last Post: 07-27-2010, 02:27 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 - Senior Forums