Gene Wirchenko wrote:
Dear Vixens and Reynards:

The scenario: you have a form with a grid on it. The user closes the form. There is a validation error, and in that case, you want the form to not close.

My solution was to add a property to the form called .griderror. In the controls that I use in the grid, the validation starts by setting .griderror to .f. and then does the validation. If there is an error, it sets .griderror to .t.. The form's .queryunload checks if .griderror is .t.. If it is, then the form close is cancelled (or the exit is confirmed, etc.).

My forms work slightly differently. When I start an edit (or add) session, nothing is checked until they want to either save or cancel the edit. If they want to save you do your validation and put up messages for any errors you find. If no errors save as normal. If they want to cancel the edit then you put up a confirm "Abandon changes?" and they can exit or not. If they exit nothing is saved and you are back to before the edit. One reason I do it this way is that my app has a "seize" timer running to take control of the app, so if I seize the system I want people out right away even if they are editing. When that happens the form will unload without the "Abandon changes?" prompt.

I don't use .queryunload at all. Just check your .griderror after your validation as to whether they can save or not.

HTH

Peter

----------------------------------------------------------------



Rajan Imports has changed - we are now Whispering Smith Ltd.  For more 
information see our website at www.whisperingsmith.com


Please update your address book with my new email address: 
[email protected]

.

This communication is intended for the person or organisation to whom it is addressed. The contents are confidential and may be protected in law. Unauthorised use, copying or disclosure of any of it may be unlawful. If you have received this message in error, please notify us immediately by telephone or email.

www.whisperingsmith.com

Whispering Smith Ltd
Head Office:61 Great Ducie Street, Manchester M3 1RR. Tel:0161 831 3700 
Fax:0161 831 3715
London Office:17-19 Foley Street, London  W1W 6DW Tel:0207 299 7960


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to