Combine multiple records into 1 subform entry

Combine multiple records into 1 subform entry

I'm wanting to combine multiple records into 1 subform line on another record however there's a catch. Here's what I need to do:

Let's say I have 5 records, each of them is linked to a product, however there are only 2 products among the 5 records. i.e

Record 1 - Product 1 - Qty 2
Record 2 - Product 2 - Qty 3
Record 3 - Product 2 - Qty 1
Record 4 - Product 2 - Qty 1
Record 5 - Product 1 - Qty 8

What I need to do is combine details from records 1 and 5 onto 1 line in a subform, and combine details from records 2,3, and 4 into another line in a subform so what I end up with is:

Subform Line 1 - Product 1 - Qty 10
Subform Line 2 - Product 2 - Qty 5

I've added the products to a list and got the distinct values, but from there I'm not sure how to proceed.