subform with FlowField based on the MainForm

babbab Member Posts: 65
Hi All,
i have a refresh problem with a SubForm.
The situation is:
there is a form (MainForm), based on Table1. on this form, there is a SubForm, based on Table2. in Table1 there is a FlowField with CalcFormula like this: Sum(Table2.Amount WHERE (No.=FIELD(No.))
i have tested 2 case:
case 1: i put this FlowField to the MainForm. when i change a record on the SubForm, the FlowField doesn't calculates, until i activate the mainform. the problem is, that i cannot refresh the MainForm from the SubForm...
case 2: i create a global variable (Name myrec, type record, subtype Table1) on the SubForm, create a function refreshsub, what calculates the value of the FlowField (myrec), and put a TextBox to the SubForm with SourceExpression like this: myrec.flowfieldname.
on the OnAfterGetRecord trigger of the MainForm, i allways call this function. it works fine, the value of the flowfield is calculated (tried it with message), but the control doesn't refresh until i activate the subform, so it shows the old value of the flowfield.
has somebody a solution for this problem?
thx

Answers

  • krikikriki Member, Moderator Posts: 9,118
    Best way is case 2, but you have to calculate it on the "OnAfterGetCurrentRecord"-trigger of the SubForm.
    You can also use the "OnAfterGetRecord"-trigger of the subform, but this will calculate the variable too many times.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Szia,

    you could just refresh the main form with an OnTimer - CurrForm.UPDATE(TRUE);

    Example: http://mibuso.com/dlinfo.asp?FileID=321
  • krikikriki Member, Moderator Posts: 9,118
    Szia,

    you could just refresh the main form with an OnTimer - CurrForm.UPDATE(TRUE);

    Example: http://mibuso.com/dlinfo.asp?FileID=321
    The problem with this system is that when you are in a field to change it and the trigger fires, you lose your change.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • kinekine Member Posts: 12,562
    It is common problem. You can:

    1) say that it is standard behaviour of Navision and teach users that if they want actual value, they need to click to the header
    2) You can add some free space with editbox on top of the subform and calc the value on subform (I assume that it is some sum of some field from the subform) - you need to calcualate it on correct trigger on the subform
    3) You can use Script shell library to simulate keypress Ctrl+Up, Ctrl+Down to refresh the header (search mibuso or mbsonline for that)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    4) If users don't like clicking on the main form, add a new menu Item, with a handy keyboard shortcut, which runs CurrForm.UPDATE(TRUE); - this is generally acceptable to end users, I did that once and first they did not like it, but finally accepted.
  • jreynoldsjreynolds Member Posts: 175
    4) If users don't like clicking on the main form, add a new menu Item, with a handy keyboard shortcut, which runs CurrForm.UPDATE(TRUE); - this is generally acceptable to end users, I did that once and first they did not like it, but finally accepted.
    In version 4.00 SP1 there is a new Refresh function. From Navision's help:
    Refresh

    Click this menu item to refresh the data that is displayed in the active window. Navision then ensures that the newest data appears in this window.

    To use this menu item, click View, Refresh.
    There is also a shortcut available (Ctrl+Alt+F5).
  • babbab Member Posts: 65
    Thx All!
    using timer and sending keys... i don't think theese are acceptable technics...
    kriki: i do the calculation in the OnAfterGetCurrentRecord trigger of the SubForm.
    It works fine :)
    but, the best solution would be, if the End User understands: this is how Navision works... :wink:
  • krikikriki Member, Moderator Posts: 9,118
    bab wrote:
    but, the best solution would be, if the End User understands: this is how Navision works... :wink:
    Well, you would have to reprogram the End User. Good Luck! :mrgreen:
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    User error, please replace user. :mrgreen:
  • ajhvdbajhvdb Member Posts: 672
    kriki wrote:
    Best way is case 2, but you have to calculate it on the "OnAfterGetCurrentRecord"-trigger of the SubForm.
    You can also use the "OnAfterGetRecord"-trigger of the subform, but this will calculate the variable too many times.

    If I have a subform which can show 10 records. How many times are "OnAfterGetCurrentRecord" and/or "OnAfterGetRecord" called?
  • krikikriki Member, Moderator Posts: 9,118
    ajhvdb wrote:
    If I have a subform which can show 10 records. How many times are "OnAfterGetCurrentRecord" and/or "OnAfterGetRecord" called?
    "OnAfterGetCurrentRecord" is triggered only for the current selected record.
    "OnAfterGetRecord" is triggered for ALL records that are shown.

    If you want a good idea, put a message in the triggers, and then count the times a message pops up. You will be surprised how many times Navision updates the records.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • babbab Member Posts: 65
    kriki wrote:
    Well, you would have to reprogram the End User. Good Luck! :mrgreen:

    i don't know, which hacker was creating the End Users' kernel, but it is fully with bug... :lol:
Sign In or Register to comment.