The following loop deletes all the orders for a particular customer, using the customer ID number to find their orders in the Order table:

function deleteAllOrders

   do while form.orders1.rowset.findKey(form.custID.value) 

      form.orders1.rowset.delete() 

   enddo 

Note that if there are no orders in the table initally, the DO WHILE condition will fail, and nothing will happen.