1 Reply Latest reply on Mar 12, 2012 10:16 AM by philmodjunk

    Populateing a child table based on values in the parent table

    etd001

      Title

      Populateing a child table based on values in the parent table

      Post

      I have 2 tables, one called BuildingArea and another called FloorLevel.

      In the table BuildingArea theres a numeric field called numfloors that holds a numeric value (lets say 4), based on this numeric value I want to populate the FloorLevel table with the corresponding records Floor 1,Floor 2,Floor 3,Floor 4.

      In a script i'd do something like the following..

      Declare var $floor

      select $floor=numfloors from BuildingArea where record = record from inserted

      for $I = 1 to $floor

      insert "Floor "+$I into FloorLevel

      Next $I

      Any ideas?

        • 1. Re: Populateing a child table based on values in the parent table
          philmodjunk

          I'm assuming that you have this relationship:

          BuildingArea::BuildingID = FloorLevel::BuildingID

          #Perform script from BuildingArea layout
          Set variable[$Floor ; value: BuildingArea::numfloors ]
          Set variable[$BuildingID ; value: BuildingArea::BuildingID]
          Freeze Window
          Go to Layout [FloorLevel]
          Loop
            Set Variable [$K ; value $K + 1]
            Exit Loop if [$K > $Floor]
            New Record/Request
            Set Field [FloorLevel::BuildingID; $BuildingID]
            Set Field [FloorLevel::Floor ; "Floor " & $K]
          End Loop
          Go to Layout [original layout]