VALIDATION in OnNextRecord !!

pskannaapskannaa Member Posts: 138
I m checking some of fields validation on OnNextRecord() trigger...if fields validations are not satifiy do not want to allow to naviagate the next,previous records...

i put the code on OnNextRecord()
fnValidate;

IF bIsError THEN
BEGIN
MESSAGE('Please enter the Mandatory Fields ' + strError) + ' !!');
EXIT(false); //Not working
END;

AFTER SHOWING THE MESSAGE, THE FORM WILL BE CLOSED, I WANT TO APPEARE THE SAME RECORD UNLESS FILL THE DETAILS/DELETE ...

How can i control this, Exit(false) is not working on NextRecord...

Comments

  • matttraxmatttrax Member Posts: 2,309
    MESSAGE is just like a warning. It only displays the text.

    ERROR will produce an error message and stop the remaining code from executing.
  • SavatageSavatage Member Posts: 7,142
    How are you handling Mandatory fields if the user simply closes the form?

    There's got to be hundred mandatory field posts.
  • pskannaapskannaa Member Posts: 138
    1. Even if i put 'ERROR', after the error message the form will be closed.

    2. I hav checked the manditory, when FORM CLOSE & NEXT,PREVIOUS NAVIGATION...

    .....Find with Form Close trigger(onquearyclose), but i can't control when i click NEXT(navigate record) button...

    In 'OnQuearyClose' --> calling manditory function, if true show error and EXIT(FALSE)

    but 'OnNextRecord' ??? i put onAfterGetRecord also..NO EFFECT
    IF bIsError THEN
    BEGIN
    Rec := xRec;
    xRec.TRANSFERFIELDS(Rec);
    CurrForm.UPDATE(FALSE);
    ERROR('Please enter the Mandatory Fields ' + DELSTR(strError,STRLEN(strError),1) + ' !!');
    END;
  • SavatageSavatage Member Posts: 7,142
    Is this a main table like Vendor, item, customer. Then you could set the blocked to true oninsert.
    The onvalidate on the blocked field you could put
    testfield('myfmandatoryfield1')
    testfield('myfmandatoryfield2')
    etc.

    if one of them is blank then it wouldn't let you unblock the record. Then the only way to use the record is to make sure all the fields are filled.

    IF it's not like that have you thought of trying something like this.
    If "MyMandatoryField" = '' THEN BEGIN
    MESSAGE('This field cannot be blank %1',"MyMandatoryField");
    CurrForm."MyMandatoryField".ACTIVATE;
    END;


    Also Set the property "Not Blank"
Sign In or Register to comment.