Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sedna has been released
Message
From
15/12/2008 18:51:12
 
General information
Forum:
Visual FoxPro
Category:
VFPX/Sedna
Environment versions
Visual FoxPro:
VFP 9
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01285787
Message ID:
01367683
Views:
18
If my current report statement is:

Report form x noconsole preview window Report

how would I tie this listener in to do its work?



>Hi Cathy,
>
>I just came up with this... here is a technique of addressing the issue programatically by using the ReportListener class. It needs more testing, but it seems to work on a few of my reports I tested.
>
>(I know it is not ideal, but I think it is better than staying on SP1)
>
>
>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
>
Previous
Reply
Map
View

Click here to load this message in the networking platform