>DEFINE CLASS rlFixGroup AS ReportListener > >Groups = NULL > >************************************* >FUNCTION BeforeReport() > LOCAL loData AS Object > LOCAL lnCnt > ** Stuff all of our group bands into a collection > This.Groups = CREATEOBJECT("Collection") > SET DATASESSION TO (This.FRXDataSession) > SELECT frx > lnCnt = 0 > SCAN FOR INLIST(objcode,3,5) && GroupHeader, GroupFooter > DO CASE > CASE objcode = 3 && GroupHeader > lnCnt = lnCnt + 1 > loData = CREATEOBJECT("Empty") > ADDPROPERTY(loData,"expr", frx.expr) > ADDPROPERTY(loData,"currentvalue", "") > ADDPROPERTY(loData,"applyfix", .F.) > ADDPROPERTY(loData,"groupheaderid",RECNO()) > ADDPROPERTY(loData,"groupno",lnCnt) > This.Groups.Add(loData,ALLTRIM(STR(RECNO()))) > > CASE objcode = 5 && GroupFooter > ** For our footer band, just use the header band but add > ** it to the collection again so we can reference it by its key > FOR EACH loData IN This.Groups > IF loData.groupno=lnCnt > ADDPROPERTY(loData,"groupfooterid",RECNO()) > This.Groups.Add(loData,ALLTRIM(STR(RECNO()))) > lnCnt = lnCnt - 1 > EXIT > ENDIF > ENDFOR > ENDCASE > ENDSCAN > SET DATASESSION TO (This.CurrentDataSession) > >ENDFUNC > >************************************* >FUNCTION BeforeBand(nBandObjCode, nFRXRecNo) > IF INLIST(nBandObjCode,3,5) > WITH This.Groups(ALLTRIM(STR(nFRXRecNo))) > DO CASE > CASE nBandObjCode = 3 && GroupHeader > ** First time through this grouping? > ** Just add our expression value to the groups object > IF EMPTY(.CurrentValue) > .CurrentValue = EVALUATE(.expr) > ENDIF > ** Is the group expr value different? > ** If so, our BUG had occured: > ** Skip back 1 record and set a flag > IF .CurrentValue != EVALUATE(.expr) > SKIP -1 > .ApplyFix = .T. > ENDIF > CASE nBandObjCode = 5 && GroupFooter > ** Reset the group expr value if our page footer occurs > .CurrentValue = "" > ENDCASE > ENDWITH > ENDIF >ENDFUNC > >************************************* >FUNCTION AfterBand(nBandObjCode, nFRXRecNo) > IF INLIST(nBandObjCode,3) && GroupHeader > WITH This.Groups(ALLTRIM(STR(nFRXRecNo))) > ** Our BUG occured, set the record pointer back > IF .ApplyFix > SKIP 1 > .ApplyFix = .F. > ENDIF > ENDWITH > ENDIF >ENDFUNC > >ENDDEFINE >