Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any Ideas?? Not to exit application.

Status
Not open for further replies.

Nick34

Technical User
Oct 16, 2003
50
0
0
US
I have some code that prompts people to close a report at a particular juncture. Most people that will be using this particular database may not understand that I do not want them to close the entire database.

Is there any way to prevent the application from closing if they should hit that close button and then prompt them to close ONLY the report instead of them pushing the close report button???
 
I would try to use the report's on close event. Check to see if the app has been exited and if so cancel the command and then direct the correct form to open
 
How can I check to see if the app has been exited??
 
your right - instead of checking the status. just do docmd.cancelevent. that will stop whatever event is in process and then docmd.close, acreport.....

that is a simpiler solution.
 
So how do I say...

If application.quit = true then
DoCmd.cancelevent
elseif application.quit = false then
Exit sub
End if

I know this will not work, but I don't know how to do what your suggesting.
 
Nick,

There are a lot of write-ups about this. I have answered the question enough that I put some comments up on my website, in the Developers' section.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
How would you make the first form that opens invisible?? I don't see anything to control that.
 
Is there a way to disable the close button on the title bar?? The one that closes the database, not the report.
 
First off, and I should have thought about this before posting, this is the type of question that should be in one of the technical forums, not here. Not a big deal, but I certainly would rather keep this forum focussed on the issues of _being a developer_, rather than technical issues.

That said, you can make any form invisible. And using my method _does_ disable that X, though it doesn't hide it.

If you want to get into this in greater detail, post a thread on the Modules forum, and I'll get back to you there.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Shoot. Now I look like an idiot, don't I? You did post in that forum. I answered in that forum. I was just looking somewhere els when I wrote that last bit. Sorry for that.

Now I guess I owe you some more technical help, huh? <G>

I'll get back to you in about a half hour. I have to look productive for a bit. I just wanted to get the appology out there right away. Sorry for the confusion.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
No problem at all. Thanks. I'll be waiting...
 
To open a form without making it visible:
call docmd.OpenForm(&quot;frmName&quot;,,,,,acHidden)

To make a form that's already open invisible:
forms!frmName.visible = false

Read through the page again. What will happen is that when a user clicks the X to close the application, a message box will appear, telling the user to close all forms and then close the application.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Nick24,

Maybe instead of telling them to close the report have a pop up subform that says something like &quot;Click 'OK' to continue&quot; and the 'OK' button simply closes the pop up form and the report at the same time.

Hope that makes sense.
 
Not to confuse the issue too much, but one other solution would be to create a module-level variable (or a control) named something like boolCloseForm. Default the value to false. In the OnClose event for the form, check this value. If false, then DoCmd.Cancel event. The final step would be to create a button on the form that sets this variable to true, then closes the form.

The reason this works is that closing the database would attempt to close this form. When that attempt fails, the database close would fail. However, when the user clicks your button it would close.

This is essentially JeremyNYC's solution simplified to work for one form only. (Which is what it sounds like you want to do.) I recommend, however, using JeremyNYC's solution to keep the user from accidentally exiting your database except by using an approved (by you) method. I do this in all of my databases.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top