Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2009
    Posts
    5

    Wink Unanswered: Close form from report?

    I have a form with three input fields and a control button that calls a macro to open a report. Two fields have a source control and one in unbound. The query looks at the form fields. When the report button is pushed the report appears. I have coded a close form when the report closes, this works. Problem is form is still open while report runs, I would like it to close. I have tried the set command in a second macro, with no luck. Tried this on many form events.
    [Forms]![Year_to_date_loan_selection_form].[Visible]

    Any one know how to close the form?

  2. #2
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    Make the form invisible just prior to opening the report;

    Behind the button, add the code

    Forms!Year_to_date_loan_selection_form.Visible = false

    ...Just before the bit that opens the report

    If the query is used for the report refers to controls on the form, the form needs to remain open so that the controls can be referenced - doing the above should be fine although you could just make it visible after the report closes so:

    User opens report - when closed back to original form.

    Give that a try and good luck.
    Last edited by garethdart; 01-30-09 at 13:04.
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  3. #3
    Join Date
    Jan 2009
    Posts
    5
    Since the open is in a macro. where do I put the code below? can I call the macro from code builder?
    Quote Originally Posted by garethdart
    Make the form invisible just prior to opening the report;

    Behind the button, add the code

    Forms!Year_to_date_loan_selection_form.Visible = false

    ...Just before the bit that opens the report

    If the query is used for the report refers to controls on the form, the form needs to remain open so that the controls can be referenced - doing the above should be fine although you could just make it visible after the report closes so:

    User opens report - when closed back to original form.

    Give that a try and good luck.

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Macros suck. Use VBA!
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Sep 2006
    Posts
    265
    Choices: Close the Form

    Open Report ...
    Close Form

    Or:

    Open Report
    Open Form ... Hidden

    then
    On Close Report

    Close Form

    Or

    Open Form Normal

    Simon

  6. #6
    Join Date
    Jan 2009
    Posts
    5
    Perfect

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •