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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to bypass valid procedure when QueryUnload 1

Status
Not open for further replies.

Toman

Technical User
Mar 30, 2004
190
CZ
Hi,

There is a combo box on a form with some testing in valid procedure. If test is not successful, procedure ends with RETURN 0 to prevent leaving the control.

Testing has no sense when the user is about to leave the form with Cancel-like button. Solution for such situation was discussed here sooner (thread1254-839231). But I'd like to suppress validation also when Query unload occurs (shutting down the form via clicking the "X").

Any suggestions?

Thank you in advance.
Tom
 
Tom,

You don't need to worry about QueryUnload. Just test the form's ReleaseType property within the Valid:

Code:
* Valid event
IF THISFORM.ReleaseType = 0
  * Do the normal validation
ELSE
 * Form is being closed; do nothng
ENDIF

This has the advantage of also detecting the form being closed via the system menu or by closing the entire application.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike,

thank you very much for your great tip.
I am sorry, I can't resist and I'm adding the text I have finished just now and was going to place it here like my answer to my question. In the morning there was my question still unanswered. I was to slow. You are the winner, the star for you.


SOLVED (may be)
I've got an idea to exploit here ReleaseType Property of a form. It happily gets value 1 (Close menu command or close box) immediately after X button is clicked (sooner then valid or LostFocus procedure get place).
So to bypass validation it is enough to place following bit of code at the beginning of valid procedure
Code:
IF Thisform.ReleaseType = 1
   MESSAGEBOX ("Sorry, no validation, X button pressed ")
   RETURN
ENDIF
Tom.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top