Snippet to create child records (Tasks) and update parent record

So what I am doing is I have a model called Receipts (Receipts__c). The model starts out empty and the user can add any number of Receipt Rows and link them to a Matter via a lookup field called Receipts__c.Matter__c. I am trying to create a model of all Matters where the Receipt__c.Matter__r.Id = the Matter__c.Id so I can perform an update only on the Matter records related to the Receipts I just inserted but it does not return anything based on my condition so I was wondering how you made it so you could update only the RequestedMedRecs related to the Tasks you inserted in your example. Thanks for your help.