Total of Sub Form in Main form

Total of Sub Form in Main form

Hi
I am new to Zoho Creator and started to create forms

I am creating a Main-form and sub form 
Main Form Contains Trip Details
Sub Form Containes Trip Materials
One Trip can contain many materials.
I want the total quantity of materials entered in sub form to be displayed in main form

Field Deluge Name for total in main form is : TOTMT
Field Deluge Nameto enter qty in sub form :  LQTMT

So the total of LQMT is to be displayed and stored in TOTMT as and when the user types in LQTMT

I already tried using the example code in following link.But its showing error.
https://www.zoho.com/creator/help/tutorials/advanced-app-building.html#Subform-Actions

Needed your guidance to proceed further.