Subformlink multiple selection

KyleaKylea Member Posts: 39
We have a Customer table with a <Cust No.> and a <Cust 2 No.> field on it.

We also have an allotment table on which <Cust No.> and <Cust 2 No.> may have received the same allotment - ie they bought it in partnership.

We have created a customer card with a subform (the subform is over the Allotment table). We want to list all allotments related to the Customer selected. The trick is that the Customer may have purchased allotments as either <Cust No.> or <Cust 2 No.> field.

Ideally it would be nice to have a subform link of the following:

Cust No.=FIELD(No.) or Cust 2 No. = FIELD(No.)

OK - back in the real world now.....I know there is no OR relationship.

Has anyone coded a subform to mark records so that both selection sets can be processed - can this be done,....any suggestions? :?: :?: :?:

Cheers


Kylea White
Senior Developer

Comments

  • krikikriki Member, Moderator Posts: 9,110
    You need to create a function in your subform. This function receives the master record and must mark all the records to show and at the end do a Currform.UPDATE(FALSE);

    In the OnAfterGetCurrentRecord of the header, you need to call the function in the subform. Remember to give your subform a name, otherwise you can't access it.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • KyleaKylea Member Posts: 39
    Hi,

    Thankyou for your help Kriki. :D:D:D

    Following your instructions this is what I did.

    1) Removed existing subform link from Customer Card. F21

    2) Added function [MarkAllotRecs] with parameter to receive Rec as per below to subform F50128
    MarkAllotRecs(Grower : Record Customer)
    CLEARMARKS;
    
    RESET;
    SETCURRENTKEY("Grower No.");
    SETRANGE("Grower No.",Grower."No.");
    IF FIND('-') THEN
      REPEAT
        MARK(TRUE);
      UNTIL NEXT = 0;
    
    //Unfilter Grower No.
    SETRANGE("Grower No.");
    SETCURRENTKEY("JV 2 Grower No.");
    SETRANGE("JV 2 Grower No.",Grower."No.");
    IF FIND('-') THEN
      REPEAT
        MARK(TRUE);
      UNTIL NEXT = 0;
    
    SETRANGE("JV 2 Grower No.");
    SETCURRENTKEY("Global Dimension 2 Code","No.");
    MARKEDONLY(TRUE);
    CurrForm.UPDATE(FALSE);
    

    3) Add code to Customer Card OnAfterGetCurrRecord as per below.

    Form - OnAfterGetCurrRecord()
    
    CurrForm.AllotList.FORM.MarkAllotRecs(Rec);
    

    Hopefully someone else will get some benefit from this.

    Thanks again.


    Kylea White
Sign In or Register to comment.