Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Is there a way to tell why a form is closing?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Max Moor - 15 May 2008 00:37 GMT
Hi All,

       I keep a left side  navigation form open all the time in my app.  On it
is a list of all the open forms in the remaining MDI space.  When a new form
is opened, it adds itself to that list.  When the user closes the form, it
removes itself.

       The list is really a listbox tied to a table with all the forms that
might be open listed.  A Yes/No field tracks if the form is open or not.  The
intent was to have this table remember what was open, and have the left-nav
form reopen the last open forms each time the app starts.

       I stuck the remove-from-list call in the forms' close events.  
Unfortunately, these fire as the app shuts down, so the list is always
emptied, and the app always opens with and empty forms space.

       What event or other mechanism can I use to tell the difference between
the user closing the form with a close button, and the form just closing
because the app is exiting?

Regards,
Max
Steve Sanford - 15 May 2008 05:28 GMT
In most of my forms, the only way to close a form is to click on a"Close"
button.

First, in the form properties, on the FORMAT tab, set the "Close button"
property to NO.

Then add a button control to the form. Name it "btnClose". For the click
event, add this:

Private Sub btnClose_Click()
 ' your code to remove-from-list call goes here
 ' remove-from-list (or whatever you call it)

  DoCmd.Close acForm, Me.Name
End Sub

Now the remove-from-list call only runs when the button is clicked  :D

HTH
Signature

Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)

> Hi All,
>
[quoted text clipped - 18 lines]
> Regards,
> Max
Max Moor - 15 May 2008 05:52 GMT
=?Utf-8?B?U3RldmUgU2FuZm9yZA==?= <limbim53 at yahoo dot com> wrote in
news:BDE4AAC9-8D1E-44D6-A684-7174016D084F@microsoft.com:

> In most of my forms, the only way to close a form is to click on
> a"Close" button.
[quoted text clipped - 15 lines]
>
> HTH

Hi Steve,

       Thanks for the reply.  Sorry I didn't cover the whole story better.
   I'm actually doing what you suggest in a couple of forms now, but I
   don't want to.  What I have is an app where all open forms maximize
   into the entire MDI space.  Currently, I use an 'X' label with an
   OnClick event that does as you suggested.  What I really wanted was
   for the system close button to be available in the menu bar (standard
   maximized form stuff), but be able to trap that click, or something.
   Effectively, I want to tell the difference between a
   system-close-button-close and a close for any other reason.

Regards,
Max
Steve Sanford - 16 May 2008 03:55 GMT
Max,

I did some searching...there are some examples of using APIs with forms on
"The Access Web" (mvps.org/access/api/index.html).... mostly changing form
size.
Maybe you could develop something from the examples. For me, its like the
joke about the roof......... It's (API programming) way over my head! :P

I use the button code because it is easy and I can modify it. I have a
template form with my form design - the close button is one control I have on
the template. It is  quicker to delete it than recreate it on new forms.

Anyway, sorry I couldn't help you.
Signature

Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)

> =?Utf-8?B?U3RldmUgU2FuZm9yZA==?= <limbim53 at yahoo dot com> wrote in
> news:BDE4AAC9-8D1E-44D6-A684-7174016D084F@microsoft.com:
[quoted text clipped - 33 lines]
> Regards,
> Max
Max Moor - 16 May 2008 19:20 GMT
=?Utf-8?B?U3RldmUgU2FuZm9yZA==?= <limbim53 at yahoo dot com> wrote in
news:5E3BBB4A-1E91-4352-B3BF-2D2AADA05E10@microsoft.com:

> Max,
>
[quoted text clipped - 11 lines]
>
> Anyway, sorry I couldn't help you.

Hi Again Steve,

       I think I'm going to stick with the same thing. the little x label
looks just like the real thing, and as you say, I can control it easily.  
The only real difference is that it's in the form space and not the menu
bar space.  The only person that is ever going to care is the anal
retentive developer that put it there.  :-)

       At any rate, I appreciate your replies.  Even if I didn't get the
answer I hoped for, it's good to have a second opinion on things.

Regards,
Max
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.