* On a test form * Put an "MS ADO Data control" and "MS Hierarchical Flexgrid Control" * Name grid control "Hflex", ADO control "ADOData" - or change below * ADOData.init #Define TESTDATALOC C:\ddrive\TEMP\testdata.DBC strCn = [Provider=MSDataShape.1;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;";Data Provider=MSDASQL ] strShp = [SHAPE { select Company, cust_id from customer } ]+; [APPEND (( SHAPE { select distinct First_name, Last_name, a.emp_id + cust_id as "Emp_sel", cust_id from employee a inner join orders b on a.emp_id = b.emp_id } ]+; [APPEND (( SHAPE { select order_date, order_net, shipped_on, emp_id + cust_id as "Emp_sel",order_id from orders } ]+; [APPEND ( { select order_id, line_no, prod_name from orditems inner join products on products.product_id = orditems.product_id } AS rsOrditems ]+; [RELATE order_id TO order_id )) AS rsCustomers ]+; [RELATE emp_sel TO emp_sel )) AS rsOrders ]+; [RELATE cust_id TO cust_id ) ] With this .CommandType = 1 .ConnectionString = strCn .RecordSource = strShp Endwith * Prepare HFlex Grid with ThisForm.HFlex .Datasource = ThisForm.ADOData.object for ix = 1 to .Cols - 1 .MergeCol(ix) = .t. && Merge cols endfor .FormatString = "<Customer Name |<Customer Id" && First band headers .GridColorBand(1) = rgb(255,0,0) && Play with gridline coloring .GridColorBand(2) = rgb(0,0,255) .GridColorBand(3) = rgb(0,255,0) .ColWidth(2,1) = 0 && Make some cols invisible .ColWidth(3,1) = 0 .ColWidth(3,2) = 0 .ColWidth(0,3) = 0 .MergeCells = 3 endwithCetin