problems using close [x] button when closing forms. 
Author Message
 problems using close [x] button when closing forms.

Hi,

I've come up against a problem closing forms which I just can't seem
to work around.

I have an application using 12 forms. Instead of loading them all at
run time, I load one form at a time, then unload it when I need to
load the next form:

i.e.

Unloaad FormX
Set FormX = nothing
Load FormY
FormY.Show vbModal

Now, I can load and unload forms using code similar to that above when
attached to command buttons or menu entries.

However, I want to use the close [x] button to unload the current form
and load the start-up form, instead of terminating the entire
application.

Is this possible (it must be) ? I have been using various permutations
of
Query_Unload, but I usually end up with either two forms showing, or
the application terminating.

Can anyone help with this ?

Thanks

Neil



Fri, 02 Jan 2004 05:26:22 GMT  
 problems using close [x] button when closing forms.
I seem to have no problems using:

Private Sub Form_QueryUnload(Cancel As Integer, _
UnloadMode As Integer)
  Me.Hide
  frmMain.Show
End Sub

A few question, though.  Do you want every displayed form to be modal? Is
your last form modal and not your first, or vise versa?

Howard Henry Schlunder


Quote:
> Hi,

> I've come up against a problem closing forms which I just can't seem
> to work around.

> I have an application using 12 forms. Instead of loading them all at
> run time, I load one form at a time, then unload it when I need to
> load the next form:

> i.e.

> Unloaad FormX
> Set FormX = nothing
> Load FormY
> FormY.Show vbModal

> Now, I can load and unload forms using code similar to that above when
> attached to command buttons or menu entries.

> However, I want to use the close [x] button to unload the current form
> and load the start-up form, instead of terminating the entire
> application.

> Is this possible (it must be) ? I have been using various permutations
> of
> Query_Unload, but I usually end up with either two forms showing, or
> the application terminating.

> Can anyone help with this ?

> Thanks

> Neil



Fri, 02 Jan 2004 07:00:19 GMT  
 problems using close [x] button when closing forms.
Basically you have to keep a 'strand of execution' alive.

Each form has its own 'strand' - so does starting up the App from Sub
Main.

You could (as HHS pointed out) just load up another form, or you could
have a control loop in the Sub Main() - making copious use of Sleep.

On Sun, 15 Jul 2001 23:00:19 GMT, "Howard Henry Schlunder"

Quote:

>I seem to have no problems using:

>Private Sub Form_QueryUnload(Cancel As Integer, _
>UnloadMode As Integer)
>  Me.Hide
>  frmMain.Show
>End Sub

>A few question, though.  Do you want every displayed form to be modal? Is
>your last form modal and not your first, or vise versa?

>Howard Henry Schlunder



>> Hi,

>> I've come up against a problem closing forms which I just can't seem
>> to work around.

>> I have an application using 12 forms. Instead of loading them all at
>> run time, I load one form at a time, then unload it when I need to
>> load the next form:

>> i.e.

>> Unloaad FormX
>> Set FormX = nothing
>> Load FormY
>> FormY.Show vbModal

>> Now, I can load and unload forms using code similar to that above when
>> attached to command buttons or menu entries.

>> However, I want to use the close [x] button to unload the current form
>> and load the start-up form, instead of terminating the entire
>> application.

>> Is this possible (it must be) ? I have been using various permutations
>> of
>> Query_Unload, but I usually end up with either two forms showing, or
>> the application terminating.

>> Can anyone help with this ?

>> Thanks

>> Neil



Fri, 02 Jan 2004 15:45:46 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Prevent user from closing form using caption close button

2. How to prevent user closing a mdi form using the close control button

3. Form Close Button Does Not Close the Form

4. Form does not close from the UpperRight X Close button

5. Do not close form on clicking close button in Visual Basic

6. Problems Closing a New Window using window.close()

7. Forms, primary thread closing when closing startup form

8. Problem with Close button on forms

9. validate a textbox when windows is closed by pressing close button [X]

10. Automatically closing down Access using code after a Modal window has been closed

11. Closing a form and closing Word

12. Tip : VB.NET Form Won't Close on Me.Close + User Controls

 

 
Powered by phpBB® Forum Software