lparameters oReport local lnIndex, lcTable, lnRow, lnTableCount, lcUniqueName, lcTempCursorName, ; loSect, loRpt, loSubRpt if vartype(oReport) = "O" if !directory(This.cOutputPath) md (This.cOutputPath) endif *--------------------------------------------------- * Handle subreports * CR doesn't currently (as of v8.5) support * subreports more than one level deep. * But if it ever does, this should still work. *--------------------------------------------------- for each loSect in oReport.Sections for each loRpt in loSect.ReportObjects if loRpt.Kind = 5 && Subreport loSubRpt = oReport.OpenSubReport(loRpt.SubReportName) This.SetTableInfo(loSubRpt) endif endfor endfor *------------------------------------------------------- * Run through all of the tables used in this report * and search for a matching cursor in This.aRptCursors * If one is found, copy the cursor to a temporary table * then tell CR to point to that table instead. *------------------------------------------------------- *!* I shredded most of the unnecessary crap here. EJK *!* There is no need to add cursors from the report GUI since we *!* loop through the table collection anyway. So just make sure any *!* table in the report or subreports has an active/open cursor of *!* the same name as the table used to design the report layout. lnTableCount = oReport.Database.Tables.Count for lnIndex = 1 to lnTableCount lcUniqueName = right(sys(2015),9) lcTempCursorName = addbs(This.cOutputPath) + lcUniqueName + ".dbf" lcTable = oReport.Database.Tables.Item[lnIndex].Name if used(lcTable) select (lcTable) *!* If the temporary table already exists, remove it. if file(lcTempCursorName) erase file (addbs(This.cOutputPath) + lcUniqueName) endif *!* Create a DBF out of the cursor, and get CR to use that copy to (lcTempCursorName) type fox2x use in select(lcUniqueName) *!* Set the data source to the temporary table oReport.Database.Tables(lnIndex).SetTableLocation(lcTempCursorName, lcUniqueName, "") oReport.discardsaveddata() endif endfor if This.lAutoVerify oReport.Database.Verify() endif endif