Hi Pete,
Here is a simple code for your problem (If I understand you well of course :-)
There are two tables:
CUSTOMERS & ORDERS, table ORDERS is ordered by Customers
SELECT Customers
GO TOP
o = ThisForm.oleTree
uniq_key = 0
SCAN
uniq_key = uniq_key + 1
oNode = o.nodes.add(,1,ALLTRIM(STR(uniq_key))+"_",ALLTRIM(CustName),,)
oNode.Image = "Closed"
oNode.ExpandedImage = "Opened"
SELECT ORDERS
SEEK Customers.Code
get_key = uniq_key
SCAN WHILE Customer == Customers.Code
unic_key = unic_key + 1
oNode = o.nodes.add(ALLTRIM(STR(get_key))+"_",4,ALLTRIM(STR(uniq_key))+"_", ALLTRIM(Orders.Name),,)
oNode.Image = "Closed"
oNode.ExpandedImage = "Opened"
ENDSCAN
SELECT Customers
ENDSCAN
HTH
Boris
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.