Error in summing and counting a subform data

Error in summing and counting a subform data

Hi there I made a form with a subform, where I want to add products names and quantities by adding a line for each new product, I then made another two boxes, where i want to count(product names) and sum (quantities), i did:

input.Refer_ncias_com_erro = clientes.count(referencias);
input.Quantidade_Total = clientes.sum(qtd);


but it doesn´t seem to be counting and summing, can anybody give a hand? thank you in advance