Lookup dates problem

Nav_NavNav_Nav Member Posts: 7
Hi,

I have 2 fields: "Month No." and "Month Name". I try to make a dynamic lookup for "Month No.", so that I can use the date table to fill both fields.

This code is written in the OnLookup trigger of "Month No."
Dates.RESET;
Dates.SETRANGE("Period Start",DMY2DATE(1,1,0001),DMY2DATE(1,12,0001));
Dates.SETRANGE("Period Type",Dates."Period Type"::Month);

IF FORM.RUNMODAL(123456703,Dates) = ACTION::LookupOK THEN BEGIN
  "Month No." := Dates."Period No.";
  "Month Name" := Dates."Period Name";
  MESSAGE(FORMAT(rec));
END;

Everything works perfect and the message shows exactly the record I want, except: I can't get to actually fill the record fields! No matter what I try, the record stays empty in the table. Even using a global variable doesn't seem to work; nav seems to forget the value after the onlookup has ended.

What could be the problem here? And: should my fields have a table relation?

Comments

  • kapamaroukapamarou Member Posts: 1,152
    Do you modify your record by Calling rec.MODIFY or CurrForm.SAVERECORD after your code fills the fields?
  • Nav_NavNav_Nav Member Posts: 7
    Since I run the table (not a form), and my code is in that table, I assume you suggest adding 'rec.MODIFY' at the end of my OnLookup trigger?

    Doing this doesn't solve the problem.
  • kinekine Member Posts: 12,562
    Try to open the table and do the lookup on some form. Do not test it when running the table directly from Object designer. Have you same problem?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Nav_NavNav_Nav Member Posts: 7
    No, making a form based on the table solves the problem. Thanks!
  • kinekine Member Posts: 12,562
    It is common that lookup code called from table started from Object designer is not commiting the changes. It is like when you start dataport directly from designer...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.