Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120

    Unanswered: Close Report, Open Form

    Sounds easy. Actually, it is. That is, when the user closes the report with the 'Close' button.
    But when they close the report using the 'X' in the upper right hand corner though....

    Here is the code I have in the report's Close Event:

    Private Sub Report_Close()
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "MENU"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    End Sub

    This code does not work if you close the report with the 'X'.

    Can I code it to close the report & open the form even if the user click's the 'X' ? (I have code to remove the 'X' and the toolbars, but then there'd be no way out !!)

    Thank you for any suggestions.

    Michael

  2. #2
    Join Date
    Mar 2004
    Location
    San Diego
    Posts
    45
    This always works for me when using the X to close:

    Code:
    Private Sub Report_Close()
        DoCmd.OpenForm ("frmName")
    End Sub

    I don't see why your wouldn't work. Maybe use the parentheses instead of the commas??

  3. #3
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120
    Thank you LaurelLee.

    It works fine when closing the report with the "Access" 'X'

    It closes the application down when closing the report with the "Windows" 'X'.

  4. #4
    Join Date
    Oct 2003
    Location
    US
    Posts
    343
    On Close event works even if you press the "Close" button on the form or report menu. There must be something else going on if your code is not executing.

  5. #5
    Join Date
    Mar 2004
    Location
    San Diego
    Posts
    45

    Smile

    Michael, are you trying to get the form to open when the user closes the database? That is what I am gathering from your response. What do you mean by the Windows 'X'? There is a box to close the report, a box to close the access window, and a box to close the entire session of Access. Be more specific, por favor.

  6. #6
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120
    The Application Window 'X'.

    I have code to get rid of that 'X', but the boss wants to keep all ways out available (don't ask :{ )

    The code works if user Clicks
    1 - The word Close on the Preview toolbar
    2 - The Report 'X' in upper right corner
    3 - File/Close

    The only scenario it doesn't work is the 'X' that closes the Application.
    I tried to explain to the boss that the 'X' is an internal Windows event (API ?), but she says there has to be a way it can be coded.

    Is there a way?
    (Remember - I do have code that disables the application 'X' but can't use it)

    Thank you all and have a good weekend !!

    Michael

  7. #7
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Thumbs up

    Hi Michael,

    Talk to your boss for as the others have stated what your boss evidently wants is something nobody outside of Microsoft can do. All that you can code and have anything to do with are the "X" on the Access windows whether it be Forms, Reports or whatever. You can create Dialog type Forms and disable the "X" forcing the user to Click on a button you choose, but seems you told your boss that already. Seems your boss is not being very bright upstairs and needs to get real.
    When you Close your Report and wish for a form to open, just do as noted earlier in this post. After the Database is CLOSED that will also Close all Forms, Reports or whatever, so if they want that to happen, IT WON'T. NOT in VBA. That is code that works across the Microsoft Office spectrum. What they should in effect do is send you to training for VisualBasic. Then you have control of what happens once the Office programs are Closed. But once more, tell your boss that when the database closes, IT CLOSES EVERYTHING!!!! You have gotten some good help/suggestions on here. Seems your boss just might want to get rid of you by asking something that can't be. I truly hope not.

    have a nice one,
    Bud

Posting Permissions

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