Form that tries to create a new record

FermiFermi Member Posts: 27
Hello, friends!

I've made a form which shows records from a table, after filtering them for a field. When the value of that field changes in a record, the form won't show it any more.

My problem is that when there is only one record that gets into the filter of the form and I change the value of the field that determines the filter, suddenly appears the no. series form, and asks me to select a numeration series.

I think it happens because the form tries to open a record that fits into the filter. If there isn't any record, the form attempts to create a new one, and then it asks for the no. series.

My customer doesn't want that it happens, and I've tried many things: I tried to place a CurrForm.CLOSE in the OnAfterValidate of the field, but it didn't work. I put CurrForm.CLOSE in On Validate, but the sistem told me that i can't run that order in that trigger. I used DelayedInsert property, but it causes more problems.

If any of you could help me, I'd be grateful

Thanks in advance
Best Regards,

Manuel Barral Paul

Comments

  • KowaKowa Member Posts: 925
    In a card form there always needs to be a SETRANGE without parameters
    on the primary key field(s) in the OnAfterGetRecord-Trigger to clear the filters from the link. Is this missing ?
    Kai Kowalewski
  • FermiFermi Member Posts: 27
    Hello,

    It was missing really. But now, I've created the setrange and the no. series form keep appearing, so I'm afraid it doesn't solve the problem.

    Really, the form tries to insert a new record, because the code that makes the no. series form appear is in the OnInsert trigger.
    Best Regards,

    Manuel Barral Paul
  • kinekine Member Posts: 12,562
    What about the property DelayedInsert on the form? Turn it on...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • FermiFermi Member Posts: 27
    I tried that property, but it created another problems, because there is some code in OnInsert thas is important to be run when user leaves the field No. (the primary key in this case).

    I finally solved the issue placing an error in the OnNewRecord trigger of the form. A function turns true a boolean variable, and if this variable is true, I've inserted an error message (withou message in this case). If you put code wuth an error in the OnNewRecord trigger, form will be closed, and it's true! :D

    Thank you for your help.
    Best Regards,

    Manuel Barral Paul
Sign In or Register to comment.