View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Corey Corey is offline
external usenet poster
 
Posts: 363
Default Correct code to Exit Userform, with out Unloading data

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" wrote in message
...
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
DTHIS
www.nickhodge.co.uk


"Corey" wrote in message
...
So if you .Hide THEN Unload, the values are not updated into a sheet?

But Unload without .Hide does ?
Corey...
"Nick Hodge" wrote in message
...
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
DTHIS
www.nickhodge.co.uk


"Corey" wrote in message
...
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" wrote in message
...
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
DTHIS
www.nickhodge.co.uk


"Corey" wrote in message
...
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....