function MyDetails() lnSelect = select() select otherdata lcText = "" scan for sub_detail_condition lcText = lcText + Fld1 + chr(13) endscan select( lnSelect ) return( lcText )If you need fields seperately in their own columns, I would suggest building a preliminary cursor to hold the original data fields add allow more fields to the cursor to hold the "extra" fields that need to be printed for the sub-details. Have one final field to identify that "this record is for sub-details".
select fld1, fld2, fld3, fld4,; space(10) as sub_fld1, 00000.00 as sub_fld2,; space(30) as sub_fld3, .F. as IS_DETAIL; from MainTable; into cursor TmpReport */ Now re-open as updateable cursor use (dbf()) again alias TmpReport2 in 0 */ Now scan through and add any necessary details select TmpReport2 scan */ Keep current key field for grouping... CurKey = TmpReport2.fld1 select otherdata scan for sub_condition insert into TmpReport2 ( fld1, sub_fld1, sub_fld2, sub_fld3, is_detail ); values ( CurKey, otherdata.fld1, otherdata.fld2, otherdata.fld3, .t. ) endscan select TmpReport2 endscan */ Now build an index keeping whatever key field grouped together index on fld1 tag tmptag1 */ Now run the report report form ...Now, just add your extra fields to the report with the "Print When" = IS_DETAIL.