building insert query for sub forms