Closing a form and report

Posted on 2012-08-20
Last Modified: 2012-08-20
Hi all,

My Problem.

I have a Main Form from where I can click on a button which takes me to another form, i.e. Report Menu.

In this Report Menu I can enter a date range i.e. a Start date and and an End Date and preview a Report based on that criteria.

To preview the report I run a macro which opens the Report and then Hides the Report Menu and then maximizes the report.

The reason I do this is because I want the Report Menu Form to continue running in hidden mode so that the report can continue running based on the date criteria entered in the Report Menu form.

My problem now is closing the Report and Report Menu form in such a way so that when  I Close the report the underlying form i.e. the Report Menu will also close so that when I re-enter the Report Menu via the Main Menu the Report Menu date range does not retain the date range that I entered previously.

Any Ideas welcomed..
Question by:PipMic
    LVL 10

    Expert Comment

    what about adding javascript on the onclose event?
    Is that feasible?
    LVL 47

    Accepted Solution

    You can use the Report_Close event.

    Private Sub Report_Close

        if currentproject.allforms("frm_Report_Menu").isloaded then
            docmd.close acform, "frm_Report_Menu"
        end if

    End sub

    Author Comment


    My eport Menu form is called "Report Menu"...

    I tried the following:-

    Private Sub Report_Close()

     If currentproject.allforms("Report Menu").isloaded Then
            DoCmd.close acForm, "Report Menu"
        End If

    End Sub

    I get a

     Compile Error
    Variable not defined

    ?? (Forgot to mention that I use A97 and A03) - I always forget to mention this!!!!
    LVL 47

    Expert Comment

    by:Dale Fye (Access MVP)
    Where did you put the code (in the report or in the form)?

    Which line was highlighted when the error occurred?  Try compiling your code, that should highlight the offending line of code, maybe you misspelled something.

    Author Comment


    Got it to work....

    Used an adaptation of the code used ie

    Private Sub Report_Close()

            DoCmd.close acForm, "Report Menu"
    End Sub

    Thanks fyed
    (Strange because I had tried something similar earlier!!!!)

    Author Closing Comment

    used part of the code thanks....

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    Article by: Leon
    Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now