Set escape on && Handy to interrupt long listings Clear Local oRecordset,oConnection, strCn, strShp _Screen.fontname = "Courier New" _Screen.fontsize = 10 Dimension aFontStyles[4,2] aFontStyles[1,1] = .t. aFontStyles[2,2] = .t. aFontStyles[3,1] = .t. aFontStyles[3,2] = .t. #Define TESTDATALOC C:\ddrive\TEMP\testdata.DBC oRecordset = CreateObject("adodb.recordset") oConnection = CreateObject("adodb.connection") strCn = [Data Provider=MSDASQL;Persist Security Info=False;]+; [Data Source="Data Provider = MSDASQL;]+; [DSN=Visual FoxPro Database;UID=;SourceDB=TESTDATALOC;]+; [SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;]+; [Deleted=Yes;"] strShp = [ SHAPE ]+; [(SHAPE {select customer.cust_id, customer.Company, orders.order_id from customer ]+; [ inner join orders on customer.cust_id = orders.cust_id where customer.cust_id like 'A%' } ]+; [ APPEND ({select od.order_id, od.unit_price * od.quantity as ExtendedPrice ]+; [ from orditems as od} AS rsDetails RELATE order_id TO order_id), ]+; [ SUM(rsDetails.ExtendedPrice) AS OrderTotal, ANY(rsDetails.order_id)) AS rsOrders ]+; [ COMPUTE rsOrders, ]+; [ SUM(rsOrders.OrderTotal) AS CustTotal, ]+; [ ANY(rsOrders.Company) AS Comp ]+; [ BY cust_id ] With oConnection .Provider = "MSDataShape" .ConnectionString = strCn .Open Endwith With oRecordset .ActiveConnection = oConnection .Source = strShp .Open Endwith oRecordset.MoveFirst Set alte on Set alte to check1.txt Set alte on ListFields("",oRecordset,0) Set alte off Set alte to Modi comm check1.txt Function ListFields Lparameters tcSetName, toRecordSet, tnTab Local lcRecord SetFont(tnTab) If toRecordSet.Recordcount > 0 Do while !toRecordSet.EOF lcRecord = space(tnTab*4) For Each ofield In toRecordSet.Fields With ofield If type(".Value") # "O" lcRecord = lcRecord + transform(.Value) + space(4) Else && Another recordset is encountered ? ? lcRecord lcRecord = "" loRecordSet = ofield.Value ListFields(.Name, loRecordSet, tnTab + 1) && Recurse with new set Endif Endwith Endfor If !empty(lcRecord) ? lcRecord Endif SetFont(tnTab) toRecordSet.MoveNext Enddo Endif Function SetFont Lparameters tnTab _Screen.fontbold = aFontStyles[tnTab%4+1,1] _Screen.fontitalic = aFontStyles[tnTab%4+1,2]However if you're going to bind an Activex FlexGrid or HierarchialFlexGrid datasource I suggest you use MS Datacontrol instead of Adodb.connection (might be possible but I coldn't succeed).