Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error form: should close activeform

Status
Not open for further replies.

mpgalvin

Programmer
Feb 5, 2001
119
IE
I have an error form which is called ON ERROR, displaying the relevant error and writing to a text file, etc.

Now, in case the error is a major one that stops the user from continuing on (eg., it may be an error in the GotFocus() event of the first control on the form, meaning an infinite loop, etc) I want to close down the form that caused the error.

To make matters even more complicated, if the error occurs in the Load() event, then the ActiveForm object doesn't exist yet, so I can't use that.

How would I go about do this sort of thing? Any code lying around, just longing to be stolen ;-)
 
While not exactly answering your question, see my response for general VFP error handling in thread184-155094.

Rick
 
Rick, if you're talking about the link to Stonefield contained in that post, thanks. But I came across that site a couple weeks ago, and the Error Handling isn't exactly what I'm looking for.

None of the options given allow you to stop the current form (either stop loading it or unload it if it's already loaded). You can either continue, ignore, retry or stop the whole application, none of which really appeal to our customers.

It also looks pretty complicated :)
 
Well I guess I was trying to imply that using an ON ERROR routine is not necessarily the best way to go in an OOP environment. (That's the way I did back in the FoxPro 2.0 days!) For FORM errors, forms should handle them, for textboxes they should handle them, etc. When you develop your base classes, you can put in this basic error handling and never have to worry about it again. Only if you need "special" handling do you need to add any more code. (The code could even call a routine similar to the one that you describe, identifying themselves and what the problem is - and it could still be the decision point as to the appropriate action.)

In an event driven OOP environment, it's often the case that a little bit of "complicated" planning, can save you much time and trouble later.

Rick
 
Okay, point taken, but even so, assuming I bring up the error message on its own form or in a messagebox, I still have the problem of how to "quit" the current form, assuming the form has been loaded, or stop loading if it hasn't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top