In your loops, each record is being assigned to the same (1st) record in each block. Sure, you create a timer which issues a NEXT_RECORD
, but this is by far the worst possible idea - and doesn't work anyway because by the time the timer actually executes, most (if not all) of your loops have already finished. There's nothing in your loop that waits for the timer to finish before it goes onto the next record - in fact, it probably creates and destroys the timer many times before the timer ever gets a chance to actually run!
Don't use timers for this sort of thing. You need to call NEXT_RECORD
within your loop.
Also, I'd recommend you don't put this sort of code in PRE-FORM
- instead, put it in your WHEN-NEW-FORM-INSTANCE
trigger.
Even better, you should base the blocks on the table (put the predicate in the DEFAULT_WHERE
property) and execute the query, instead of using this procedural code.