Inconsistent 'Order by' in form and form printing

Hi All,

This is driving me nuts :x . This is my problem simplified. I have a table of itmes. Each item has an itemid and a positionid which is used to list items and sub items. example:

Itemid positionid descriptions
100 101 Main Item 1
100 102 Sub item of 1 - 1
100 103 Sub item of 1 - 2
200 201 Main item 2
200 202 Sub item of 2 - 1
200 203 Sub item of 2 - 2

I use these fields so that when I run this query

Select * from items where quotenumber = x order by itemid asc, positionid asc

I get all the itmes listed in proper heirarchial order. I also have written methords that allows a user to later on highlight a main item in a portal row and add another sub item.

My problem is that these display all in my desired order on screen but when I go to print this form, if a user has added sub items later, even though they have the correct itemid and positionid to sort (and I have checked with an external SQL tool), the ‘extra’ items added just list at the bottom of the list:

Example - Initial order

100 101
100 102
200 201
200 202

then - highlight 100 101 and add a sub item so

100 101
100 102
100 103
200 201
200 202

But - they print out like this:

100 101
100 102
200 201
200 202
100 103

As though the query has not worked. Yet it clearly does on screen. I have checked my code over and over. Is this an issue with printing forms???

I am using :
Servoy Developer
Version R2 2.2rc6-build 324
Java version 1.4.2-38 (Mac OS X)

AND MySQL 4.0.13

Dave