What about using a try-catch construct wherever there is a posibility of an error being generated? Then you would know exactly what error appears, even before you try to close the form, and give the user a chance to correct it.

However, if the grid is a data entry one, you would probably put validation code in the textboxes of the columns valid event. In that case I use a textbox property, which I call "lValidate", initialized in the init event of the textbox, then when the user enters an invalid code, the validate method can use this property to either let him go to the next column or stay in the same one until the input is valid.

Rafael Copquin

El 25/10/2013 19:43, Gene Wirchenko escribió:
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.).

This works in my limited testing. I does seem somewhat of a kludge. Is this a good way to handle it, or is there something better that I have overlooked?

Sincerely,

Gene Wirchenko



[excessive quoting removed by server]

_______________________________________________
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