if I made
GROUP ON CU->STATE ;
FOOTER " » Total FOR STATE » "+::oReport:aGroups[1]:cValue +"("+ltrim(str(::oReport:aGroups[1]:nCounter))+")" ;
FONT 1
oReport:nCounter is right for each group and the total counter is right
If I not use Groups but only easy bfor sample :
ACTIVATE REPORT oReport FOR dInicio <= CU->HIREDATE .AND. CU->HIREDATE <= dFinal ;
ON END ( oReport:StartLine(), oReport:EndLine(), oReport:StartLine(), ;
oReport:Say(1, 'Total customers: '+Tran(oReport:nCounter, '@E 999,999'), 1),;
oReport:EndLine() )
give me bad nCounter
SO IFI wish print only the hiredate from 01/01/1990 to 01/011991
execute the codeblock bfor ( FOR dInicio <= CU->HIREDATE .AND. CU->HIREDATE <= dFinal ) because it print only 57 records
then print on say "total customers " 500
why ?
here the test (rep21.prg)
- Code: Select all Expand view RUN
#include "FiveWin.ch"
#include "report.ch"
request DBFCDX
STATIC oReport
Function Rep21()
LOCAL oFont1, oFont2, oFont3, oPen1, oPen2
local dInicio :=ctod("01/01/1990")
local dFinal :=ctod("01/01/1991")
DEFINE FONT oFont1 NAME "ARIAL" SIZE 0,-10
DEFINE FONT oFont2 NAME "ARIAL" SIZE 0,-10 BOLD
DEFINE FONT oFont3 NAME "ARIAL" SIZE 0,-10 BOLD ITALIC
DEFINE PEN oPen1 WIDTH 3
DEFINE PEN oPen2 WIDTH 1
USE CUSTOMER NEW VIA "DBFCDX" ALIAS CU
// index on cu->state tag 1 temporary
CU->(DbGoTop())
REPORT oReport ;
TITLE "*** FiveWin Report DEMO ***",;
"",;
OemtoAnsi("by FiveTech"),;
"" ;
FONT oFont1,;
oFont2,;
oFont3 ;
PEN oPen1,;
oPen2 ;
HEADER "Date: "+dtoc(date()),;
"Time: "+time() ;
RIGHT ;
FOOTER OemtoAnsi("Page: ")+str(oReport:nPage,3) ;
CENTERED ;
PREVIEW
/*
//FOR TEST a GROUP
GROUP ON CU->State ;
FOOTER "Total State "+oReport:aGroups[1]:cValue+ ;
" ("+ltrim(str(oReport:aGroups[1]:nCounter))+")" ;
FONT 2
*/
COLUMN TITLE "ST" ;
DATA CU->State ;
FONT 2 ;
GRID 2
COLUMN TITLE "City" ;
DATA CU->City ;
GRID 2
COLUMN TITLE "First Name","Last Name" ;
DATA CU->First , CU->Last ;
GRID 2
COLUMN TITLE " Salary" ;
DATA CU->Salary ;
PICTURE "9,999,999" ;
SIZE 9 ;
TOTAL ;
SHADOW ;
GRID
END REPORT
IF oReport:lCreated
/*
First line of title bold
*/
oReport:oTitle:aFont[1] := {|| 2 }
/*
Total descriptors
*/
oReport:cGrandTotal := "Grand Total..."
oReport:cPageTotal := "Page Total..."
/*
Italic when salary greater than 100,000
*/
oReport:aColumns[4]:bDataFont := {|| iif(CU->Salary>100000,3 ,1 ) }
ENDIF
ACTIVATE REPORT oReport FOR dInicio <= CU->HIREDATE .AND. CU->HIREDATE <= dFinal ;
ON STARTGROUP oReport:NewLine() ;
ON END ( oReport:StartLine(), oReport:EndLine(), oReport:StartLine(), ;
oReport:Say(1, 'Total customers: '+Tran(oReport:nCounter, '@E 999,999'), 1),;
oReport:EndLine() )
/*
Close and release
*/
oFont1:End()
oFont2:End()
oFont3:End()
oPen1:End()
oPen2:End()
CLOSE CU
RETURN NIL
IF I made ( I saw a Nages topic)
- Code: Select all Expand view RUN
- local nCounter := 1
and then
- Code: Select all Expand view RUN
oReport:bFor := { || If((dInicio <= CU->HIREDATE .AND. CU->HIREDATE <= dFinal), (nCounter++, .t. ), .f. ) }
ACTIVATE REPORT oReport ;
ON STARTGROUP oReport:NewLine() ;
ON END ( oReport:StartLine(), oReport:EndLine(), oReport:StartLine(), ;
oReport:Say(1, 'Total customers: '+Tran(nCounter, '@E 999,999'), 1),;
oReport:EndLine() )
we have 58 records but I have only 57 records , How it was possible ?
TEST WITH GROUP
But when I use GRoup command with the suggestion of NAges then the total id not right
because the records ( with bfor) are allways 57 but the ncounter is 115