Results 1 to 5 of 5
  1. #1
    Varda is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    44

    Closing and opening report when selecting different values from a combo box

    Using Access 2010


    I have a form with a combo box, and two command buttons.



    When the user selects a record in the combo box, the command button pressed opens a report filtered by the criteria selected in the combo box.

    I'm trying to allow the user to select a different value in the combo box, and close the report that is already open, so the report can open again for the new criteria selected in the combo box.

    I'm assuming I would place the code in the On Change of the combo box. What is the code I need to place?


    Or what keywords should I search on YouTube?

    Varda

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    I would use combobox AfterUpdate event.

    You want to check if the report is already open then close it if it is.

    If CurrentProject.AllReports("reportname").IsLoaded Then

    However, if the report is open in Print Preview and is on top of the form, won't they have to close the report with X close button to get back to the form?
    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
    Varda is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    44
    Yes, the report is open in Print Preview and is "on top" of the form. The form actually stays open, and I can select a new name and run the report again - which is why I'm asking about a way to close the current report, so I can select a new name to filter the report by.

    I tried your code above, and it doesn't close the report, it just opens another tab with the new report (I have two command buttons opening a different report each).

    I'm trying to skip the step of having the user close the report on the x close button, so they can easily select a new name, and print the new report.


    Varda

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Post your code for analysis.

    Oh wait, your db is set for Tabbed Documents - I always use Overlapping Windows.
    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.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    What's the code you tried? I don't see why
    If CurrentProject.AllReports("reportname").IsLoaded Then
    docmd.close "reportname"
    docmd.open"reportname",etc.
    end if
    would not work, even for preview, even in tabbed documents. I'm sure I've done this many times. You change the combo box value, then click to re-open the report with new data.

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

Similar Threads

  1. Opening/closing Anything in Access is slow!
    By cboshdave in forum Access
    Replies: 1
    Last Post: 06-02-2015, 02:27 PM
  2. Replies: 14
    Last Post: 05-08-2013, 03:08 PM
  3. Replies: 1
    Last Post: 07-12-2012, 08:39 AM
  4. Closing 1 form and opening another
    By mulefeathers in forum Forms
    Replies: 13
    Last Post: 12-08-2011, 04:04 PM
  5. Selecting multiple values to be used in a report.
    By mnsemple83 in forum Reports
    Replies: 1
    Last Post: 08-12-2011, 05:10 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