Run a form using selected record

sbillysbilly Member Posts: 231
I have a form with a subform linked by "No."
The subform (tabular type) contain many Customer."No."
What I try to do is when I click on a Customer."No.", the related customer card launchs.
This is the code that I wrote on the OnDrillDown trigger:
ATTTLgn.SETRANGE("Customer No.");
IF ATTTLgn.FIND('-') THEN // I want to run a form using that record
BEGIN
Form.Run(21)
END;


But the form shows the last displayed record.

Comments

  • sbillysbilly Member Posts: 231
    I solved it and this is the code:
    ATTTLgn.SETRANGE("Customer No.");
    IF ATTTLgn.FIND('-') THEN
     BEGIN
      Customer."No." := "Customer No.";
      FORM.RUN(21,Customer);
     END;
    
  • krikikriki Member, Moderator Posts: 9,112
    2 small remarks:
    TTTLgn.SETRANGE("Customer No.");
    IF ATTTLgn.FINDFIRST THEN // if you need only 1 record, best use FINDFIRST (or FINDLAST). it is faster because it does not use a cursor. see also ([url]http://www.mibuso.com/howtoinfo.asp?FileID=22[/url])
    BEGIN
      Customer."No." := "Customer No.";
      FORM.RUN(FORM::"Customer Card",Customer); // best use this instead of an integer. It is clearer and easier to find after a lot of time.
    END;
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.