What is the cleanest, safest way to abort a form in the load event? For example, if a particular condition is not satisfied and we don't want the user to continue.
Printable View
What is the cleanest, safest way to abort a form in the load event? For example, if a particular condition is not satisfied and we don't want the user to continue.
Is GoodCode:Unload Me
Keep code out of the Load event and put it in a Public form function:
Load Myform
Result = Myform.OpenFunction
If Result = Fail Then
Unload.Myform
Else
Myform.Show [vbModal/vbModeless]
End if
;)
Sam: No its not!!! (OK it is, but only in the most simplistic scenarios)
Jerry: Looks promising - I'll try it
Thanks
If it's the First thing in the Load Event it's doing pretty much the Same thing as Jerry's Code. Or is there something I'm missing?
in Sam's defense...the question was how to abort..
the answer is correct...
however, prevention should outweight reaction!
"If the condition is not met the form should never be
loaded."
Conditions should be checked before load is
called. If the form has to load to check conditions then
you are not aborting you are quitting.
Have fun...just my 1 cent's worth....
I refuse to be drawn into a semantic argument!!!!!
However, "If the condition is not met the form should never be loaded." This makes sense - this, I believe, is the way to go.
Thanks all!!