How to clear mark on Lookup form?

selece28selece28 Member Posts: 316
Hi Nav masters,
I have a problems. I fill my Lookup form using records that i get with Mark.
But when the form shows, it have a Mark sign on the left side. How can i remove those Mark sign, and Put my cursor to the 1st record?

This is the example of my code:

Rec_Employee.MARKEDONLY(TRUE);
Frm_Employee.LOOKUPMODE := TRUE;
Frm_Employee.SETTABLEVIEW(Rec_Employee);
Frm_Employee.SETRECORD(Rec_Employee);
IF Frm_Employee.RUNMODAL = ACTION::LookupOK THEN BEGIN
Frm_Employee.GETRECORD(Rec_Employee);
VALIDATE("Requested By", Rec_Employee."No.");
END;

Thanks in advance
______________

Regards,
Steven

Answers

  • kinekine Member Posts: 12,562
    1) Position to the first record - use FINDFIRST or FIND('-') on the record before passing it to the form
    2) If you do not see the marks, you will need to use temporary table, into which you insert the marked records and you will pass this temporary record to the form.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • selece28selece28 Member Posts: 316
    Hi Kine,
    I already try using temporary table but still cannot.

    My code is like this: <Rec_Employee1 is temporary>

    Rec_Employee.MARKEDONLY(TRUE);
    Rec_Employee1.DELETEALL;
    Rec_Employee1.COPY(Rec_Employee); // i try Transferfields also cannot
    Rec_Employee1.CLEARMARKS;

    Frm_Employee.LOOKUPMODE := TRUE;
    Frm_Employee.SETTABLEVIEW(Rec_Employee1);
    Frm_Employee.SETRECORD(Rec_Employee1);
    IF Frm_Employee.RUNMODAL = ACTION::LookupOK THEN BEGIN
    Frm_Employee.GETRECORD(Rec_Employee1);
    VALIDATE("Requested By", Rec_Employee1."No.");
    END;

    How to do it?
    Thanks in advance
    ______________

    Regards,
    Steven
  • kinekine Member Posts: 12,562
    problem is in:
    Rec_Employee1.COPY(Rec_Employee); // i try Transferfields also cannot 
    

    COPY function doesn't copy records! It just copy filters and sorting, but not records. You need to go through all the records in a loop and insert them into the temporary.
    if Rec_Employee.FINDSET then
    repeat
      Rec_Employee1 := Rec_Employee;
      Rec_Employee1.INSERT;
    until Rec_Employee.NEXT=0;
    

    (And I recommand to use name like TempRec_Employee or something like that with the Temp or Buffer in the name to clearly state, that the record is Temporary table).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • selece28selece28 Member Posts: 316
    Hi Kine,
    I already follow your instruction.
    But now i have all records instead of the records that only i mark.
    Weird...

    I put my code in table (on lookup) and not in form, is it correct?

    Thanks in advance
    ______________

    Regards,
    Steven
  • kinekine Member Posts: 12,562
    Can you re-send your new code?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • selece28selece28 Member Posts: 316
    Hi Kine,
    This all my code: <Rec_TempEmployee is the temporary table>

    Rec_TempEmployee.DELETEALL;
    Rec_Employee.MARKEDONLY(TRUE); //i found 3 records
    IF Rec_Employee.FINDSET THEN //i also try Find('-'), cannot too
    REPEAT
    Rec_TempEmployee := Rec_Employee;
    Rec_TempEmployee.INSERT;
    UNTIL Rec_Employee.NEXT = 0;

    Frm_Employee.LOOKUPMODE := TRUE;
    Frm_Employee.SETTABLEVIEW(Rec_TempEmployee);
    Frm_Employee.SETRECORD(Rec_TempEmployee);
    IF Frm_Employee.RUNMODAL = ACTION::LookupOK THEN BEGIN
    Frm_Employee.GETRECORD(Rec_TempEmployee);
    VALIDATE("Requested By", Rec_TempEmployee."No.");
    END;

    Is there anything i miss?

    Thanks in advance
    ______________

    Regards,
    Steven
  • kinekine Member Posts: 12,562
    May be that problem is in the way of calling the form. Better will be to use this:
    Rec_TempEmployee.DELETEALL;
    Rec_Employee.MARKEDONLY(TRUE); //i found 3 records
    IF Rec_Employee.FINDSET THEN //i also try Find('-'), cannot too
    REPEAT
      Rec_TempEmployee := Rec_Employee;
      Rec_TempEmployee.INSERT;
    UNTIL Rec_Employee.NEXT = 0;
    
    IF FORM.RUNMODAL(0,Rec_TempEmployee) = ACTION::LookupOK THEN BEGIN
      VALIDATE("Requested By", Rec_TempEmployee."No.");
    END; 
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • selece28selece28 Member Posts: 316
    Wow Thanks Kine, My problems solved
    ______________

    Regards,
    Steven
Sign In or Register to comment.