Multiple "for each line" statements

Multiple "for each line" statements

Hi,

I'm still learning syntax so i'm hoping this is as simple as rephrasing / combing, but i basically have a couple instances where i want to use an expression to apply in two different ways, but it seems i can't use "for each line" twice like this.

(On load)

  1. for each line in Prod_subform
  2. {
  3.     line.Previous = true;
  4. }
  5. for each line in Misc_Subform
  6. {
  7.     line.Previous2 = true;
  8. }



(On Success)
    1. subformContent = "";
    2. subformContent2 = "";
    3. for each line in Prod_subform
    4. {
    5.     if (!line.Previous)
    6.     {
    7.         //fetch product records
    8.         get_products  =  Products_Form  [ID = line.Products];
    9.         //fetch container records
    10.         get_containers  =  Containers_Form  [ID = line.Containers];
    11.         subformContent = (((((((subformContent + "[" + line.Qty + " <b>x</b> " + get_containers.Containers_Database) + "]") + " <b>of ") + get_products.Products_Database) + "</b> for $[") + line.Price) + "]") + "<br><br>";
    12.     }
    13. }
    14. for each line in Misc_Subform
    15. {
    16.     if (!line.Previous2)
    17.     {
    18.         //fetch equipment records
    19.         get_equipment  =  Equipment_Lab_Form  [ID = line.Equipment_Lab_Database];
    20.        
    21. subformContent2 = ((((subformContent2 + "[" + line.Qty + " <b>of</b> " + get_equipment.Equipment_Lab_Database) + "] for $[") + line.Price + "] ") + "Notes: ") + line.Notes + "<br><br>";
    22.     }
    23. }

    Previous & Previous2 are decision boxes. How do i phrase the code properly, if you can see what i'm trying to do?