Form and subform issue

nromainnromain Member Posts: 57
hello,

I encounter a strange problem on a V5 sql (i have not try yet on an other version).
i have a form with a field with a lookup which call a form with a subform. The subform needs to be filter on a date range present on my first form. So i have create 2 functions (one in the form called by the lookup, one in the subform) to transfer the date range.

example :

code in the lookup of the field

Myform.SetDateRange(StartingDate,EndingDate);
Myform.RUN;

code in the function setdaterange of Myform

CurrForm.SubForm.FORM.SetDaterangeOnSubform(StartingDate,EndingDate);

in the SetdateRangeOnSubform function, I only apply date filters.

The result is OK, the subform is correctly filtered with the two dates but a very strange thing appears :

The form and subform seem to be separated, as if the subform was called directly. Moreover, the task bar of Navision disappears (File/Edit/Tools etc... unavailable)... This is strange !

Somebody can help me?

Thank you !
Nicolas

Answers

  • kapamaroukapamarou Member Posts: 1,152
    Out of curiosity... try the following.

    Pass the parameters to Global Vars in your main form and the call the subform function from a trigger like OnAfterGetCurrentRecord to see what happens...
  • nromainnromain Member Posts: 57
    It works ! thank you !

    But can you explain why my way doesn't work?
  • kapamaroukapamarou Member Posts: 1,152
    I suppose that the way your code was before, it caused an update to apply the filters before the parent form was actually created with the subform, causing it to open separately. Probably with missing Parent Form... :?:
  • dorenthasdorenthas Member Posts: 31
    I ran into a similar issue, and when I read this post, I smacked myself on the forehead for not thinking about it ](*,)

    I had a function in a subform that used CurrForm.UPDATE and CurrForm.UPDATECONTROLS, and the function was called by another function (let's name it InitForm) in the parent form; the InitForm function was sometimes called by the OnOpenForm trigger of the parent form (which yielded the correct behavior) and sometimes from code in other NAV objects (which caused the same issue nromain had).

    The solution was to ensure that the InitForm function was never called if the form was not open; this was achieved by ensuring that the only code calling the InitForm function was the OnOpenForm trigger of the parent form.
Sign In or Register to comment.