//Link the Item_Name field in subform to the Item_name field in Items Form;
selected_item = Items[ID = row.Item_name];
//Set the quantity of the selected product to 1 by default, if no quantity is declared
if(row.Quantity = null)
{
row.Quantity=1;
}
if(row.Quantity > selected_item.Quantity)
{
alert "Please select a lesser quantity";
}
//Set the price of the selected product as per the Products Form
row.Item_Price=selected_item.Item_Price;
//Calculate the total amount based on the Item, Item_Price and Quantity.
tot = 0.0;
for each item in Items
{
tot = tot + item.Item_Price * item.Quantity;
}
input.Total_Amount = tot;