Tags: access, button, closes, database, form, microsoft, mysql, oracle, report, sounds, sql, user
Close Report, Open Form
On Database » Microsoft Access
3,739 words with 6 Comments; publish: Wed, 05 Dec 2007 06:11:00 GMT; (25093.75, « »)
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
http://ms-access.itags.org/q_ms-access-database_36396.html
All Comments
Leave a comment...
- 6 Comments

- This always works for me when using the X to close:
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??
#1; Tue, 11 Dec 2007 20:14:00 GMT

- 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'.
#2; Tue, 11 Dec 2007 20:15:00 GMT

- 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.#3; Tue, 11 Dec 2007 20:16:00 GMT

- 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.#4; Tue, 11 Dec 2007 20:17:00 GMT

- 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
#5; Tue, 11 Dec 2007 20:18:00 GMT

- 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
#6; Tue, 11 Dec 2007 20:19:00 GMT