Reuse subform with different table relation

tompynationtompynation Member Posts: 398
Imagine that you have a custom table containing the Field Item.

Inside this table the table relation for this field consist of:
Item.No. WHERE (Item Category Code=CONST(V))

Now i created a subform for this table...

The problem is that i would like to reuse this form now.
So on my main form i would have this subform twice.

But the table relation should switch in the second subform to:
Item.No. WHERE (Item Category Code=CONST(G))

Is it possible?

Answers

  • tompynationtompynation Member Posts: 398
    i found it, i had to declare the onLookup trigger inside the subform itself.

    Not in the table
  • JedrzejTJedrzejT Member Posts: 267
    Hi,

    Insert custom lookup code in both of subform. Diffrent filter on each lookup solve your problem.
    Something like
      LookupRec.Setfilter(type,type::"1");
      IF LookupRec.GET("Field No.") THEN;
      IF FORM.RUNMODAL(0,LookupRec)=ACTION::LookupOK THEN
        VALIDATE("Field No.",LookUpRec."No.");
    
  • DenSterDenSter Member Posts: 8,305
    You can also set the tablerelationship to just the Item number, and include the Item Category Code filter in the subform link. That way, no code at all and you can use the same subform with different filters.
  • awarnawarn Member Posts: 261
    Also remember that

    Item.No. WHERE (Item Category Code=CONST(V))

    is hardcoding - you do not want to restrict the subform based on a CONST value that could be different for different companies in teh same database!

    Best to have that field (V, G, whatever) be in a setup table somewhere, and use FILTERGROUPs along with the setup field to have the correct filtering in the subform.

    -awarn
Sign In or Register to comment.