Perform a find for all records with a given value specified in that "basket" field. Then print using the "records being browsed" option.
Sorry if my questions are dumb, new to the UI game, more or less filemaker.
How will FM know which record is currently selected and to only show the records related to it
When you change to find mode, enter some search criteria such as a value in your "Basket" field and then click Perform Find, this produces a "found set" of all records matching that value. These will be the only records visible on your layout until you perform a different find or select one of the options from the Records menu that also manipulate this found set. At this point, using Print with the "records being browsed option" selected you will get a print out from the current layout of all records in that found set.
and to only show the records related to it
Does that mean that you have two tables involved here, linked by the Basket field? That's new information not in your original post in this thread.
Yes apologies, basket name is in a different table than the item code.
Which does not mean that this method will not work. To be sure, however, it would help to know how your layout is designed.
From what I can see, it appears that you have a list view layout with a sub summary layout part serving as a "sub header". If so, then what I described should work. You should be able to enter find mode, specify the desired value in the Basket field and perform your find.
If your relationship is:
ParentRecords::Basket = LayoutRecords::MatchField
You can get a faster result by specifying this search criterion in LayoutRecords::MatchField instead of ParentRecords::Basket.