If the Cancel property of the commandbutton is set to true you can begin all of your valid code with:
if ( lastkey() = 27 )
return .t.
endif
Or look at moving the validation to a field/table level rule and don't worry about validating each control with code. This also gives the user more freedom to move around the form as they please.
>See in a master the focus is on the Primary key field.
>I want if the user presses the cancel button then no
>validations should be done. What I feel is when the user
>clicked on Cancel button I should able to know the
>current control. Is there any way to findout this?
>or any other solution.