Filter without modification

EccEcc Member Posts: 3
Hi!
I've built a tabular type form that has a table in its source and shows its contents. Than I added a textbox, set its sourceexpr to a global variable und added
    record.RESET;
    record.SETRANGE(Column, Filter);
    record.SETCURRENTKEY(OtherColumn);
    record.FINDFIRST;
to the OnValidate-Event of that textbox. Filtering works, but when the tablebox looses its focus, I get a message telling me that I cannot modify the forms source table. But i didn't change anything in the tablebox. When i put the same C/AL-Code in the OnPush-Event of a button, everything works _without_ that messagebox. How can i get rid of that message?

Thanks in advance!

Comments

  • babbab Member Posts: 65
    Put your code in the OnAfterValidate trigger, also call CurrForm.Update(FALSE) instead of FINDFIRST (it will fail if no records are found). E.g. if you have a form with sourcetable Customer, with variable NameFilter, you can use something like this:
    IF NameFilter = '' THEN
      SETRANGE(Name)
    ELSE
      SETFILTER(Name, NameFilter);
    CurrForm.UPDATE(FALSE);
    
    You can also check the standard forms like 7002, to get an idea.
  • EccEcc Member Posts: 3
    Thanks a lot, it works now. :-)
Sign In or Register to comment.