PC Review


Reply
Thread Tools Rate Thread

Correct code to Exit Userform, with out Unloading data

 
 
Corey
Guest
Posts: n/a
 
      7th Jan 2007
What is the best way to close off a userform without unloading the data.

Userform.hide simply hides the userform,
but is this good enough as a close?
As it still stores the data in the userform if something was placed there.

Corey....


 
Reply With Quote
 
 
 
 
Nick Hodge
Guest
Posts: n/a
 
      7th Jan 2007
Corey

Hide is the only way to dismiss the form and persist the data, Unload
removes it from memory and returns the controls to their design time state
and it cannot be read

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(E-Mail Removed)DTHIS
www.nickhodge.co.uk


"Corey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What is the best way to close off a userform without unloading the data.
>
> Userform.hide simply hides the userform,
> but is this good enough as a close?
> As it still stores the data in the userform if something was placed there.
>
> Corey....
>


 
Reply With Quote
 
Corey
Guest
Posts: n/a
 
      7th Jan 2007
So to clear the data that was entered and to use the .hide,
The userform should be coded to clear all values upon Initializing to
remove any values that were entered previously if the userform is then
re-.shown?

Corey....
"Nick Hodge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Corey
>
> Hide is the only way to dismiss the form and persist the data, Unload
> removes it from memory and returns the controls to their design time state
> and it cannot be read
>
> --
> HTH
> Nick Hodge
> Microsoft MVP - Excel
> Southampton, England
> (E-Mail Removed)DTHIS
> www.nickhodge.co.uk
>
>
> "Corey" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> What is the best way to close off a userform without unloading the data.
>>
>> Userform.hide simply hides the userform,
>> but is this good enough as a close?
>> As it still stores the data in the userform if something was placed
>> there.
>>
>> Corey....
>>

>



 
Reply With Quote
 
Nick Hodge
Guest
Posts: n/a
 
      7th Jan 2007
Corey

A normal procedure would be

'UserForm1 initialisation (Either design time or runtime)
UserForm1.Show (Shows and loads into memory, fires UserForm_Initialize()
event)
'do what you want with the form
UserForm1.Hide
'Read all the controls and place or do with them what you will
Unload UserForm1
'This removes all the values and renders form unreadable (out of memory)
'Start routine again

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(E-Mail Removed)DTHIS
www.nickhodge.co.uk


"Corey" <(E-Mail Removed)> wrote in message
news:%23C3$(E-Mail Removed)...
> So to clear the data that was entered and to use the .hide,
> The userform should be coded to clear all values upon Initializing to
> remove any values that were entered previously if the userform is then
> re-.shown?
>
> Corey....
> "Nick Hodge" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Corey
>>
>> Hide is the only way to dismiss the form and persist the data, Unload
>> removes it from memory and returns the controls to their design time
>> state and it cannot be read
>>
>> --
>> HTH
>> Nick Hodge
>> Microsoft MVP - Excel
>> Southampton, England
>> (E-Mail Removed)DTHIS
>> www.nickhodge.co.uk
>>
>>
>> "Corey" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> What is the best way to close off a userform without unloading the data.
>>>
>>> Userform.hide simply hides the userform,
>>> but is this good enough as a close?
>>> As it still stores the data in the userform if something was placed
>>> there.
>>>
>>> Corey....
>>>

>>

>
>


 
Reply With Quote
 
Corey
Guest
Posts: n/a
 
      7th Jan 2007
So if you .Hide THEN Unload, the values are not updated into a sheet?

But Unload without .Hide does ?
Corey....
"Nick Hodge" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Corey
>
> A normal procedure would be
>
> 'UserForm1 initialisation (Either design time or runtime)
> UserForm1.Show (Shows and loads into memory, fires UserForm_Initialize()
> event)
> 'do what you want with the form
> UserForm1.Hide
> 'Read all the controls and place or do with them what you will
> Unload UserForm1
> 'This removes all the values and renders form unreadable (out of memory)
> 'Start routine again
>
> --
> HTH
> Nick Hodge
> Microsoft MVP - Excel
> Southampton, England
> (E-Mail Removed)DTHIS
> www.nickhodge.co.uk
>
>
> "Corey" <(E-Mail Removed)> wrote in message
> news:%23C3$(E-Mail Removed)...
>> So to clear the data that was entered and to use the .hide,
>> The userform should be coded to clear all values upon Initializing to
>> remove any values that were entered previously if the userform is then
>> re-.shown?
>>
>> Corey....
>> "Nick Hodge" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Corey
>>>
>>> Hide is the only way to dismiss the form and persist the data, Unload
>>> removes it from memory and returns the controls to their design time
>>> state and it cannot be read
>>>
>>> --
>>> HTH
>>> Nick Hodge
>>> Microsoft MVP - Excel
>>> Southampton, England
>>> (E-Mail Removed)DTHIS
>>> www.nickhodge.co.uk
>>>
>>>
>>> "Corey" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> What is the best way to close off a userform without unloading the
>>>> data.
>>>>
>>>> Userform.hide simply hides the userform,
>>>> but is this good enough as a close?
>>>> As it still stores the data in the userform if something was placed
>>>> there.
>>>>
>>>> Corey....
>>>>
>>>

>>
>>

>



 
Reply With Quote
 
Nick Hodge
Guest
Posts: n/a
 
      7th Jan 2007
Corey

Hiding keeps the form in memory and therefore the values in any controls
(You will have to do something with them, nothing happens automatically).
Providing you DON'T unload it you can continue to use the same values, or
different ones if you either re-show the form or change the
values/properties of controls in code.

Once you unload the form, the data in the controls are gone, forever and you
can do nothing with them until you re-show the form and reset the values of
the controls, etc.

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(E-Mail Removed)DTHIS
www.nickhodge.co.uk


"Corey" <(E-Mail Removed)> wrote in message
news:OmVqv$(E-Mail Removed)...
> So if you .Hide THEN Unload, the values are not updated into a sheet?
>
> But Unload without .Hide does ?
> Corey...
> "Nick Hodge" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Corey
>>
>> A normal procedure would be
>>
>> 'UserForm1 initialisation (Either design time or runtime)
>> UserForm1.Show (Shows and loads into memory, fires UserForm_Initialize()
>> event)
>> 'do what you want with the form
>> UserForm1.Hide
>> 'Read all the controls and place or do with them what you will
>> Unload UserForm1
>> 'This removes all the values and renders form unreadable (out of memory)
>> 'Start routine again
>>
>> --
>> HTH
>> Nick Hodge
>> Microsoft MVP - Excel
>> Southampton, England
>> (E-Mail Removed)DTHIS
>> www.nickhodge.co.uk
>>
>>
>> "Corey" <(E-Mail Removed)> wrote in message
>> news:%23C3$(E-Mail Removed)...
>>> So to clear the data that was entered and to use the .hide,
>>> The userform should be coded to clear all values upon Initializing to
>>> remove any values that were entered previously if the userform is then
>>> re-.shown?
>>>
>>> Corey....
>>> "Nick Hodge" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> Corey
>>>>
>>>> Hide is the only way to dismiss the form and persist the data, Unload
>>>> removes it from memory and returns the controls to their design time
>>>> state and it cannot be read
>>>>
>>>> --
>>>> HTH
>>>> Nick Hodge
>>>> Microsoft MVP - Excel
>>>> Southampton, England
>>>> (E-Mail Removed)DTHIS
>>>> www.nickhodge.co.uk
>>>>
>>>>
>>>> "Corey" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> What is the best way to close off a userform without unloading the
>>>>> data.
>>>>>
>>>>> Userform.hide simply hides the userform,
>>>>> but is this good enough as a close?
>>>>> As it still stores the data in the userform if something was placed
>>>>> there.
>>>>>
>>>>> Corey....
>>>>>
>>>>
>>>
>>>

>>

>
>


 
Reply With Quote
 
Nick Hodge
Guest
Posts: n/a
 
      7th Jan 2007
Corey

I think the key here is nothing (updating cells, etc) happen automatically,
you need to set the values on the sheet from the hidden form, then when you
have done this and need the values no longer, unload the form.

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(E-Mail Removed)DTHIS
www.nickhodge.co.uk


"Corey" <(E-Mail Removed)> wrote in message
news:OmVqv$(E-Mail Removed)...
> So if you .Hide THEN Unload, the values are not updated into a sheet?
>
> But Unload without .Hide does ?
> Corey....
> "Nick Hodge" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Corey
>>
>> A normal procedure would be
>>
>> 'UserForm1 initialisation (Either design time or runtime)
>> UserForm1.Show (Shows and loads into memory, fires UserForm_Initialize()
>> event)
>> 'do what you want with the form
>> UserForm1.Hide
>> 'Read all the controls and place or do with them what you will
>> Unload UserForm1
>> 'This removes all the values and renders form unreadable (out of memory)
>> 'Start routine again
>>
>> --
>> HTH
>> Nick Hodge
>> Microsoft MVP - Excel
>> Southampton, England
>> (E-Mail Removed)DTHIS
>> www.nickhodge.co.uk
>>
>>
>> "Corey" <(E-Mail Removed)> wrote in message
>> news:%23C3$(E-Mail Removed)...
>>> So to clear the data that was entered and to use the .hide,
>>> The userform should be coded to clear all values upon Initializing to
>>> remove any values that were entered previously if the userform is then
>>> re-.shown?
>>>
>>> Corey....
>>> "Nick Hodge" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> Corey
>>>>
>>>> Hide is the only way to dismiss the form and persist the data, Unload
>>>> removes it from memory and returns the controls to their design time
>>>> state and it cannot be read
>>>>
>>>> --
>>>> HTH
>>>> Nick Hodge
>>>> Microsoft MVP - Excel
>>>> Southampton, England
>>>> (E-Mail Removed)DTHIS
>>>> www.nickhodge.co.uk
>>>>
>>>>
>>>> "Corey" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> What is the best way to close off a userform without unloading the
>>>>> data.
>>>>>
>>>>> Userform.hide simply hides the userform,
>>>>> but is this good enough as a close?
>>>>> As it still stores the data in the userform if something was placed
>>>>> there.
>>>>>
>>>>> Corey....
>>>>>
>>>>
>>>
>>>

>>

>
>


 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      7th Jan 2007
If controls are linked to cells, then values are updated when the cells
change - no relation to unload or hide

if you use code to write values to cells, then when the code runs the cells
are updated. No relation to unload or hide

What Nick was say is that a lot of people hide the userform (modal) so the
code that called then can continue to run. In that code, there is code to
utililize the values in the controls of the userform such as

v = Userform1.Textbox1.Value

when done extracting values, then the userform is unloaded.

If you don't need to access any values from the calling code, then by all
means, unload the userform to close it rather than using the hide command.

Understand what each method done, then utilize them appropriately to achieve
the results you need.

--
regards,
Tom Ogilvy


"Corey" <(E-Mail Removed)> wrote in message
news:OmVqv$(E-Mail Removed)...
> So if you .Hide THEN Unload, the values are not updated into a sheet?
>
> But Unload without .Hide does ?
> Corey....
> "Nick Hodge" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Corey
>>
>> A normal procedure would be
>>
>> 'UserForm1 initialisation (Either design time or runtime)
>> UserForm1.Show (Shows and loads into memory, fires UserForm_Initialize()
>> event)
>> 'do what you want with the form
>> UserForm1.Hide
>> 'Read all the controls and place or do with them what you will
>> Unload UserForm1
>> 'This removes all the values and renders form unreadable (out of memory)
>> 'Start routine again
>>
>> --
>> HTH
>> Nick Hodge
>> Microsoft MVP - Excel
>> Southampton, England
>> (E-Mail Removed)DTHIS
>> www.nickhodge.co.uk
>>
>>
>> "Corey" <(E-Mail Removed)> wrote in message
>> news:%23C3$(E-Mail Removed)...
>>> So to clear the data that was entered and to use the .hide,
>>> The userform should be coded to clear all values upon Initializing to
>>> remove any values that were entered previously if the userform is then
>>> re-.shown?
>>>
>>> Corey....
>>> "Nick Hodge" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> Corey
>>>>
>>>> Hide is the only way to dismiss the form and persist the data, Unload
>>>> removes it from memory and returns the controls to their design time
>>>> state and it cannot be read
>>>>
>>>> --
>>>> HTH
>>>> Nick Hodge
>>>> Microsoft MVP - Excel
>>>> Southampton, England
>>>> (E-Mail Removed)DTHIS
>>>> www.nickhodge.co.uk
>>>>
>>>>
>>>> "Corey" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> What is the best way to close off a userform without unloading the
>>>>> data.
>>>>>
>>>>> Userform.hide simply hides the userform,
>>>>> but is this good enough as a close?
>>>>> As it still stores the data in the userform if something was placed
>>>>> there.
>>>>>
>>>>> Corey....
>>>>>
>>>>
>>>
>>>

>>

>
>



 
Reply With Quote
 
Nick Hodge
Guest
Posts: n/a
 
      7th Jan 2007
Tom

Thanks...it's late in the day here, I was having trouble
explaining...hopefully Corey has it now

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(E-Mail Removed)DTHIS
www.nickhodge.co.uk


"Tom Ogilvy" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> If controls are linked to cells, then values are updated when the cells
> change - no relation to unload or hide
>
> if you use code to write values to cells, then when the code runs the
> cells are updated. No relation to unload or hide
>
> What Nick was say is that a lot of people hide the userform (modal) so the
> code that called then can continue to run. In that code, there is code to
> utililize the values in the controls of the userform such as
>
> v = Userform1.Textbox1.Value
>
> when done extracting values, then the userform is unloaded.
>
> If you don't need to access any values from the calling code, then by all
> means, unload the userform to close it rather than using the hide command.
>
> Understand what each method done, then utilize them appropriately to
> achieve the results you need.
>
> --
> regards,
> Tom Ogilvy
>
>
> "Corey" <(E-Mail Removed)> wrote in message
> news:OmVqv$(E-Mail Removed)...
>> So if you .Hide THEN Unload, the values are not updated into a sheet?
>>
>> But Unload without .Hide does ?
>> Corey....
>> "Nick Hodge" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Corey
>>>
>>> A normal procedure would be
>>>
>>> 'UserForm1 initialisation (Either design time or runtime)
>>> UserForm1.Show (Shows and loads into memory, fires UserForm_Initialize()
>>> event)
>>> 'do what you want with the form
>>> UserForm1.Hide
>>> 'Read all the controls and place or do with them what you will
>>> Unload UserForm1
>>> 'This removes all the values and renders form unreadable (out of memory)
>>> 'Start routine again
>>>
>>> --
>>> HTH
>>> Nick Hodge
>>> Microsoft MVP - Excel
>>> Southampton, England
>>> (E-Mail Removed)DTHIS
>>> www.nickhodge.co.uk
>>>
>>>
>>> "Corey" <(E-Mail Removed)> wrote in message
>>> news:%23C3$(E-Mail Removed)...
>>>> So to clear the data that was entered and to use the .hide,
>>>> The userform should be coded to clear all values upon Initializing to
>>>> remove any values that were entered previously if the userform is then
>>>> re-.shown?
>>>>
>>>> Corey....
>>>> "Nick Hodge" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> Corey
>>>>>
>>>>> Hide is the only way to dismiss the form and persist the data, Unload
>>>>> removes it from memory and returns the controls to their design time
>>>>> state and it cannot be read
>>>>>
>>>>> --
>>>>> HTH
>>>>> Nick Hodge
>>>>> Microsoft MVP - Excel
>>>>> Southampton, England
>>>>> (E-Mail Removed)DTHIS
>>>>> www.nickhodge.co.uk
>>>>>
>>>>>
>>>>> "Corey" <(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>> What is the best way to close off a userform without unloading the
>>>>>> data.
>>>>>>
>>>>>> Userform.hide simply hides the userform,
>>>>>> but is this good enough as a close?
>>>>>> As it still stores the data in the userform if something was placed
>>>>>> there.
>>>>>>
>>>>>> Corey....
>>>>>>
>>>>>
>>>>
>>>>
>>>

>>
>>

>
>


 
Reply With Quote
 
Corey
Guest
Posts: n/a
 
      7th Jan 2007
Nick,
If i complete the userform the values selected are input into a sheet.
Therefore if part way through the userform, i decide to cancel the userform.
IF i:
userform.hide
unload me

Still unload what data WAS entered or as it was Hiden are the values then
Deleted ?

Corey....
"Nick Hodge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Corey
>
> Hiding keeps the form in memory and therefore the values in any controls
> (You will have to do something with them, nothing happens automatically).
> Providing you DON'T unload it you can continue to use the same values, or
> different ones if you either re-show the form or change the
> values/properties of controls in code.
>
> Once you unload the form, the data in the controls are gone, forever and
> you can do nothing with them until you re-show the form and reset the
> values of the controls, etc.
>
> --
> HTH
> Nick Hodge
> Microsoft MVP - Excel
> Southampton, England
> (E-Mail Removed)DTHIS
> www.nickhodge.co.uk
>
>
> "Corey" <(E-Mail Removed)> wrote in message
> news:OmVqv$(E-Mail Removed)...
>> So if you .Hide THEN Unload, the values are not updated into a sheet?
>>
>> But Unload without .Hide does ?
>> Corey...
>> "Nick Hodge" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Corey
>>>
>>> A normal procedure would be
>>>
>>> 'UserForm1 initialisation (Either design time or runtime)
>>> UserForm1.Show (Shows and loads into memory, fires UserForm_Initialize()
>>> event)
>>> 'do what you want with the form
>>> UserForm1.Hide
>>> 'Read all the controls and place or do with them what you will
>>> Unload UserForm1
>>> 'This removes all the values and renders form unreadable (out of memory)
>>> 'Start routine again
>>>
>>> --
>>> HTH
>>> Nick Hodge
>>> Microsoft MVP - Excel
>>> Southampton, England
>>> (E-Mail Removed)DTHIS
>>> www.nickhodge.co.uk
>>>
>>>
>>> "Corey" <(E-Mail Removed)> wrote in message
>>> news:%23C3$(E-Mail Removed)...
>>>> So to clear the data that was entered and to use the .hide,
>>>> The userform should be coded to clear all values upon Initializing to
>>>> remove any values that were entered previously if the userform is then
>>>> re-.shown?
>>>>
>>>> Corey....
>>>> "Nick Hodge" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> Corey
>>>>>
>>>>> Hide is the only way to dismiss the form and persist the data, Unload
>>>>> removes it from memory and returns the controls to their design time
>>>>> state and it cannot be read
>>>>>
>>>>> --
>>>>> HTH
>>>>> Nick Hodge
>>>>> Microsoft MVP - Excel
>>>>> Southampton, England
>>>>> (E-Mail Removed)DTHIS
>>>>> www.nickhodge.co.uk
>>>>>
>>>>>
>>>>> "Corey" <(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>> What is the best way to close off a userform without unloading the
>>>>>> data.
>>>>>>
>>>>>> Userform.hide simply hides the userform,
>>>>>> but is this good enough as a close?
>>>>>> As it still stores the data in the userform if something was placed
>>>>>> there.
>>>>>>
>>>>>> Corey....
>>>>>>
>>>>>
>>>>
>>>>
>>>

>>
>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform to grab,correct and restore data jimapos Microsoft Excel Programming 1 27th Sep 2006 02:27 PM
userform get data,correct and restore dapos Microsoft Excel Programming 0 25th Sep 2006 02:34 PM
Getting error unloading Userform?? Ed Microsoft Excel Programming 3 1st Jul 2005 12:27 AM
Unloading UserForm not working Marston Microsoft Excel Programming 2 17th Aug 2004 04:18 AM
Not Unloading a UserForm Mike Microsoft Excel Programming 1 29th Jan 2004 11:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:41 AM.