Very Simple Custom Function

Very Simple Custom Function

Hi,

I have a custom module with a subform and would like to create a field to reference data inside the subform.

For example, I want a field to show the total profit of a sales order.  In the subform, The module is called Custom_Quote and the subform is called "Product Details".  I have a fields Cost_Per_Unit, Price_Per_Unit and Quantity.

In the module, I want a formula to calculate Price_Per_Unit - Cost_Per_Unit * Quantity, for all line items in the subform.

It's my understanding, that the only way to accomplish this is with a custom function.  But I have not been able to successfully write on. 

Please note that I need to do this without using the aggregate field in the subform because of the limitations of 8 fields per subform.

Any help would be appreciated!!