The method described in message #
590652 is similar to how I was attempting to do record level validation to start with. This method exhibited the same recursive calls to the validation function as the one I was using. In my validation method there are required fields that the grid will allow the user to skip. if the record is not valid, I pop up a modal wizard form that tells the user what is wrong with the record and provides suggestions and picklists to allow the user to complete the record. If the record tests as valid and does not have to pop up the modal form, it works OK, but when the wizard form pops up, it causes recursive calls to the validation method and the wizard keeps popping up until you revert the changes or kill the form with the grid. This appears to be something to do with the grid losing focus and regaining focus after the wizard form ends.
Trying to step this in the debugger caused even more recursive calls. It appears that the .AfterRowColChange is being executed each time that the grid receives focus after the modal form ends and the code line
Refer to code examples in message #
590652 IF .nRec2Validate # lnRec2GoTo
was causing the problem with recursive calls.
I modified the code in AfterRowColChange to reset .nRec2Validate to 0 to prevent the code from executing recursively when a modal form is called ffrom the grid.ValidateCurrentRow(). This seemed to work well in either case.
This is the slightly modified code that I used in AfterRowColChange event:
LOCAL lnRec2GoTo
WITH This
IF .nRec2Validate = 0
exit
endif
lnRec2GoTo = RECNO( .RecordSource )
IF .nRec2Validate # lnRec2GoTo
.lValidatingRow = .T.
GOTO .nRec2Validate IN ( .RecordSource )
IF .ValidateCurrentRow()
GOTO lnRec2GoTo IN ( .RecordSource )
.RefreshControls()
ENDIF
.lValidatingRow = .F.
.nRec2Validate = 0
ENDIF
ENDWITH
Resetting .nRec2Validate = 0 solved my recursive calls problem.
I thought I woulld pass this along. Many thanks for the quick reply.
Elmer