none
Form Closes on any cmdButton click RRS feed

  • Question

  • Hi

    I have a button on my main form which opens another form containing command buttons for all the different reports available (almost in the same way as a Switchboard).  Everything works fine but I would like the reports window to close once any of the report command buttons have been clicked.  Forms have an 'On Click' command but click on what?  I have put a close command on the 'On Click' for the form but this does not work.  Do I have to put the close command on all the report command buttons individually?

    Chris

    Tuesday, November 17, 2015 1:20 PM

Answers

  • Hi Chris,

    Yes you'll have to put the close command on each button or try the form's lost focus event.

    • Marked as answer by ChrisParkin Tuesday, November 17, 2015 2:06 PM
    Tuesday, November 17, 2015 1:52 PM

All replies

  • Hi Chris,

    Yes you'll have to put the close command on each button or try the form's lost focus event.

    • Marked as answer by ChrisParkin Tuesday, November 17, 2015 2:06 PM
    Tuesday, November 17, 2015 1:52 PM
  • Thanks DB

    Unfortunately, even though the form definitely did lose focus, placing the command in 'On Lost Focus' didn't execute it.  Anyway, copy and a few pastes later and the job is done.

    Cheers.

    Tuesday, November 17, 2015 2:09 PM
  • "Everything works fine but I would like the reports window to close once any of the report command buttons have been clicked."

    In other words you would like the reports window (Switchboard form) to close when ever a report opens.

    That sounds like a job for the "On Load" event of each report.

    Keep in mind "On Open" happens before "On Load".


    If this post answered or helped you find the answer to your question, please mark it as such for other Forum users knowledge.

    Tuesday, November 17, 2015 2:40 PM
  • Hi h2fcell; thanks for your comments.

    Applying the close command to each report cmdButton does the job nicely.  Your response suggests an alternative which, without trying yet, I'm sure would work too.  I am very interested in doing my best to build this database according to all rules and best practices associated with databases.

    So my next question would be; is it a simple choice of which way round I do it or are either of the above a preferred method under the heading 'best practice'?

    Thanks.

    Tuesday, November 17, 2015 3:03 PM
  • It really depends on what the business wants it terms of functionality.
    I use a similar approach to running reports. (Switchboard form with button controls) Some buttons open the report directly some buttons open a filtering form for date ranges.  In all cases I never close the switchboard form or filtering form.  I have all my reports always open in print preview mode with “Pop Up” = Yes and “Modal” = Yes. 

    When the user is done with the report and they close it, they can run another report from the already open switchboard or change the filtering for the same report.


    If this post answered or helped you find the answer to your question, please mark it as such for other Forum users knowledge.


    • Edited by DriveEV Tuesday, November 17, 2015 3:45 PM
    Tuesday, November 17, 2015 3:44 PM
  • Thanks DB

    Unfortunately, even though the form definitely did lose focus, placing the command in 'On Lost Focus' didn't execute it.  Anyway, copy and a few pastes later and the job is done.

    Cheers.

    Hi Chris,

    Glad to hear you got something to work. Good luck with your project.

    Tuesday, November 17, 2015 3:53 PM
  • Thanks for all your responses guys.

    Coincidentally H2, your last post describes exactly what I am doing to.  Switchboard of reports and reports are pop-up.

    Now, what I am trying to figure out at the moment is... When I close the report, focus does not automatically return to the switchboard.  So I have to click once to get focus and then again on a report button.  I have tried attaching a setfocus command to the report which does work when the report closes, but found that if the switchboard is inadvertently closed, then I get a runtime error as it cannot set focus to a closed window.  I just know that somehow, somebody will close the switchboard before closing the report so I need to find a fix for this.

    I promise to keep trying for myself but if anybody is feeling generous with assistance today and would like to see me get home in time for the footy, then please feel free to assist.

    Many thanks.

    Tuesday, November 17, 2015 4:10 PM
  • Hi Chris. So, is your "switchboard" form set as Popup and Modal? Just to confirm, are your reports Popup and Modal too?

    PS. Oh, and just to clarify, are you saying you don't want to "close" the switchboard anymore like you wanted to do in your original post?

    • Edited by .theDBguy Tuesday, November 17, 2015 4:32 PM PS
    Tuesday, November 17, 2015 4:30 PM
  • I find when you open a report or forms with “Pop Up” = Yes and “Modal” = Yes, focus moves in sequence automatically.
    Last one open has focus.
    I.e.
    Form1 opens has focus.
    Button on Form1 opens Form2, Form2 has focus. User cannot get to Form1.
    Button on Form2 opens Report, Report has focus.  User cannot get to Form2 or Form1.
    Close Report, Form2 gets focus automatically.  User cannot get to Form1.
    Close Form2, Form1 gets focus automatically.


    If this post answered or helped you find the answer to your question, please mark it as such for other Forum users knowledge.

    • Proposed as answer by DriveEV Friday, November 27, 2015 4:15 PM
    Tuesday, November 17, 2015 4:51 PM
  • Hi both... I'm getting home in time for the footy today thanks to you.

    Modal was a condition I had never yet ventured to learn; that is now with regret!!  As you guys mentioned Modal, I went off to see just what it does and found it to be the perfect solution.  When I tried it, it worked exactly how I had just learned, fixed the problem and locked everything except itself and its children - Perfect!!

    DB - How you helped me previously was for a switchboard which was purely for selecting a form to edit either Supplier, Customer, InvoiceTo, etc contacts and addresses.  So your solution for that issue remains in place.  I didn't want the reports switchboard to close as often we will need to select more than one report at a time for viewing.  Modal works great for this as the switchboard and reports remain active whilst all else is locked.

    Thank you again both.

    Tuesday, November 17, 2015 5:09 PM
  • Good to know. Thanks!
    Tuesday, November 17, 2015 5:14 PM