Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default load/unload userform

I have created a userform with an Initialize event that loads the userform
from a database.
To use the form I run

Load myForm
myForm.Show
Unload myForm

The form has an OK Button and a Cancel button which both hide the form and
then the next line of code unloads (terminates) the form.

It all works OK except when the user closes the form by clicking the form's
close button (top right cross).
When this happens the form actually terminates so when the Unload myForm
code runs, because myForm has been terminated it is first re-initialized
before it is then terminated.
Although there are no errors and it still works OK it is annoying as the
initialize event downloads quite e bit of data and so takes quite a while.

Is there any way I can find out if myForm has been terminated before I run
the Unload command.

Thanks,
Fred


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default load/unload userform

Not sure if it will help but I use the following test to control the
switching between two overlayed forms......
If the form is not initialized this will return false as well.

UserForm1.Visible = True

--
Cheers
Nigel



"Fred" wrote in message
...
I have created a userform with an Initialize event that loads the userform
from a database.
To use the form I run

Load myForm
myForm.Show
Unload myForm

The form has an OK Button and a Cancel button which both hide the form and
then the next line of code unloads (terminates) the form.

It all works OK except when the user closes the form by clicking the

form's
close button (top right cross).
When this happens the form actually terminates so when the Unload myForm
code runs, because myForm has been terminated it is first re-initialized
before it is then terminated.
Although there are no errors and it still works OK it is annoying as the
initialize event downloads quite e bit of data and so takes quite a while.

Is there any way I can find out if myForm has been terminated before I run
the Unload command.

Thanks,
Fred




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default load/unload userform

Fred,

You can trap that event, and cancel it

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
Cancel = True
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Nigel" wrote in message
...
Not sure if it will help but I use the following test to control the
switching between two overlayed forms......
If the form is not initialized this will return false as well.

UserForm1.Visible = True

--
Cheers
Nigel



"Fred" wrote in message
...
I have created a userform with an Initialize event that loads the

userform
from a database.
To use the form I run

Load myForm
myForm.Show
Unload myForm

The form has an OK Button and a Cancel button which both hide the form

and
then the next line of code unloads (terminates) the form.

It all works OK except when the user closes the form by clicking the

form's
close button (top right cross).
When this happens the form actually terminates so when the Unload myForm
code runs, because myForm has been terminated it is first re-initialized
before it is then terminated.
Although there are no errors and it still works OK it is annoying as the
initialize event downloads quite e bit of data and so takes quite a

while.

Is there any way I can find out if myForm has been terminated before I

run
the Unload command.

Thanks,
Fred






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default load/unload userform

Thanks Bob,
that works fine.


"Bob Phillips" wrote in message
...
Fred,

You can trap that event, and cancel it

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
Cancel = True
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Nigel" wrote in message
...
Not sure if it will help but I use the following test to control the
switching between two overlayed forms......
If the form is not initialized this will return false as well.

UserForm1.Visible = True

--
Cheers
Nigel



"Fred" wrote in message
...
I have created a userform with an Initialize event that loads the

userform
from a database.
To use the form I run

Load myForm
myForm.Show
Unload myForm

The form has an OK Button and a Cancel button which both hide the form

and
then the next line of code unloads (terminates) the form.

It all works OK except when the user closes the form by clicking the

form's
close button (top right cross).
When this happens the form actually terminates so when the Unload
myForm
code runs, because myForm has been terminated it is first
re-initialized
before it is then terminated.
Although there are no errors and it still works OK it is annoying as
the
initialize event downloads quite e bit of data and so takes quite a

while.

Is there any way I can find out if myForm has been terminated before I

run
the Unload command.

Thanks,
Fred








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to unload the loaded XLL file in Excel? Hi all, I amdebugging XLL link library using Visual C++. Everytime I rebuild the XLL, Ihave to close the whole Excel program and relaunch the Excel program again,and then load in the newly gene LunaMoon Excel Discussion (Misc queries) 0 July 28th 08 11:03 PM
Can't load or unload object jase[_2_] Excel Programming 1 June 9th 05 08:52 PM
unload userform from within one of that form's beforeupdate events? Andrew H[_3_] Excel Programming 1 August 10th 04 09:07 AM
Load and Unload Form commands R Avery Excel Programming 4 July 29th 04 03:16 PM
can i have VBA & forms etc load then unload? Chris A[_3_] Excel Programming 0 November 20th 03 11:14 PM


All times are GMT +1. The time now is 11:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"