OnNextRecord Stop at the current Record

Hi! I make a check in the OnNextRecord Trigger, and if the Check is false the user should not be allowed to leave the current record, but how should i stop him moving forward or backwards…i can stop him moving but then the form is cleared…my code: CheckRcp(); //this is the check....sets a flag true or false //the Flag: NeedApprover IF NeedApprover = TRUE THEN BEGIN MESSAGE('Please select an Approver!'); //HERE STOP AT CURRENT RECORD!! that's my problem END ELSE //normal steps.... BEGIN REPEAT ResultSteps := NEXT(Steps); UNTIL (ResultSteps = 0) OR ("No." <> CurrNo); EXIT(ResultSteps); END; anyone knows how to solute this? Thx!!!

Hi, I don’t think the OnNextRecord trigger is the right place to put the check or if it’s even possible. You can accomplish the effect, though, by placing the following (or similar) code in the OnAfterGetCurrRecord() trigger:OnAfterGetCurrRecord() //Example: Approve if "No." is '1' NeedApprover := (xRec."No." = '1') AND (xRec."No." <> "No."); IF NeedApprover THEN IF NOT CONFIRM('Change record - are you sure?', FALSE) THEN BEGIN Rec := xRec; CurrForm.UPDATE(FALSE); END;You’re check will probably look different, but keep in mind that the check MUST be made on xRec. This will also work if the user uses the searchoption. You might want to add some code to the OnQueryCloseForm() trigger as well.

Hi! Thx for your answer, but with that he is able to go to the next record, and that’s what i want to stop, he must take an Approver or delete the whole Invoice, but with your solution he only clicks yes and again yes and the next record is called…but thx

Well, then simply replace the CONFIRM with a MESSAGE like: OnAfterGetCurrRecord() //Example: Approve if "No." is '1' NeedApprover := (xRec."No." = '1') AND (xRec."No." <> "No."); IF NeedApprover THEN BEGIN MESSAGE('Please select an approver!'); Rec := xRec; CurrForm.UPDATE(FALSE); END;

Well…thx i tried this when i reconized the problem with yes and no…it was also not working…i am now programming a function which selects the approver automatic/randomly…but thx :slight_smile:

On your original idea, you could make the OnNextRecord trigger return 0. I think that makes the Form stay on the same record - but I’m not sure it stops you from closing it or creating a new record… Just a thought

Hi! I have already tried different return values…it always clears the form :(…anyone knows how to get the record in the form then? get(“No.”) is not working…but then i only get the “old Record” if the boolean is true…

quote:


Well…thx i tried this when i reconized the problem with yes and no…it was also not working


What do you mean? - Cut and paste the code to Form 21 for example and you’ll see that it works… As mentioned previously you have to change the codeNeedApprover := (xRec."No." = '1') AND (xRec."No." <> "No.");to suit your own needs, but the basic principle is the same or am I missing something?