>Hi all
>
>I use CodeBook as my framework. Roughly it goes like this
>
>Form
> |
>cForm
> |
>iForm
> |
>aForm
> |
>MyForm
>
>I would like to know if MyForm.BeforeSave() has returned a .F. in iForm.BeforeSave(). Now the problem is that the code in MyForm.BeforeSave() is as follows:
>
llRetVal = DODEFAULT()
>llRetVal = llRetVal AND THISFORM.pgf.Page1.txtIno.CheckForBadNextNo()
>
>IF llRetVal
>*** my stuff where somewhere it fails and llRetVal = .F.
>ENDIF
>
>RETURN llRetVal
>
>As the DODEFAULT() is executed before (I don't want to proceed if the basics have failed), but now my stuff fails and iForm will never know that there is a failure. I have put the below code but the display error when NOT llRetVal is never executed
>
LOCAL llRetVal, lcErrorMsg
>
>llRetVal = DODEFAULT()
if not m.llRetVal
>lcErrorMsg = THIS.oBizObj.GetErrorMsg()
>
>IF NOT EMPTY(lcErrorMsg)
> THIS.DisplayErrorMsg(lcErrorMsg)
>ELSE
> THIS.DisplayErrorMsg("The record has not been saved." + CHR(13) + CHR(10) ;
> + "Please provide the required details and try saving again")
> >ENDIF
>
endif
>RETURN llRetVal
>
>I have confirmed that there is a DODEFAULT() throught the coding. I am not allowed to modify the c-layer.
>
I made a slight modification in that code. If dodefault returned true you don't need to get lcErrorMsg.
But I don't see other problems and it looks like you're correct. The only other suggestion would be to move textbox validation to a form's custom method and call it in BeforeSave instead of drill-down textbox validation.
If it's not broken, fix it until it is.
My Blog