I find when creating a report that when I use group, Everything works good except when I go to GroupFooter the table has
changed records so I can not enter ending group information for the grouped record.
Am I doing something wrong .
Thanks ................ Franco
FIXED FROM FRANCO:
I read some of the old group footer posts and found this is the way to fix my problem.
I missed using the DATA ITERATOR section.
I will leave this post, maybe others can get some info from it
Thanks again ............... Franco
Code: Select all
#include "hmg.ch"
Function Main
private mbal := 0, endsec := .F. // ADDED
Set Date Ansi
Set Century On
fls() // creates temp file
select test
DEFINE WINDOW Win_1 ;
ROW 0 ;
COL 0 ;
WIDTH 400 ;
HEIGHT 400 ;
TITLE 'Hello Report' ;
WINDOWTYPE MAIN ;
ONINIT CreateReport() // creates report
DEFINE MAIN MENU
POPUP 'File'
ITEM 'Execute Report' ACTION ExecuteReport('Report1',.t.,.t.) // executes report
END POPUP
END MENU
END WINDOW
Win_1.Center
Win_1.Activate
Return
Function CreateReport
DEFINE REPORT Report1
* Report Data Environment *************************************
BEGIN DATA //ADDED
ITERATOR advan() //ADDED
STOPPER endsec = .T. //ADDED
END DATA // ADDED
* Report Layout ***********************************************
* Report Layout ***********************************************
BEGIN LAYOUT
PAPERSIZE PRINTER_PAPER_A4
ORIENTATION PRINTER_ORIENT_PORTRAIT
END LAYOUT
* Header Band *************************************************
BEGIN HEADER
BANDHEIGHT 25
BEGIN LINE
FROMROW 23
FROMCOL 10
TOROW 23
TOCOL 200
PENWIDTH 0.1
PENCOLOR { 0 , 0 , 0 }
END LINE
BEGIN TEXT
EXPRESSION 'Report Header'
ROW 13
COL 10
WIDTH 100
HEIGHT 10
FONTNAME 'Arial'
FONTSIZE 20
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Left
END TEXT
END HEADER
* Detail Band *************************************************
BEGIN DETAIL
BANDHEIGHT 6
BEGIN TEXT
EXPRESSION Test->Item
ROW 2
COL 18
WIDTH 10
HEIGHT 10
FONTNAME 'Arial'
FONTSIZE 9
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Left
END TEXT
BEGIN TEXT
EXPRESSION Test->product
ROW 2
COL 30
WIDTH 60
HEIGHT 10
FONTNAME 'Arial'
FONTSIZE 9
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Left
END TEXT
BEGIN TEXT
EXPRESSION Test->Rate
ROW 2
COL 70
WIDTH 60
HEIGHT 10
FONTNAME 'Arial'
FONTSIZE 9
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Left
END TEXT
END DETAIL
* Footer Band *************************************************
BEGIN FOOTER
BANDHEIGHT 27
BEGIN LINE
FROMROW 4
FROMCOL 10
TOROW 4
TOCOL 200
PENWIDTH 0.1
PENCOLOR { 0 , 0 , 0 }
END LINE
BEGIN TEXT
EXPRESSION 'Page. No:' + Str(_PageNo)
ROW 7
COL 11
WIDTH 100
HEIGHT 10
FONTNAME 'Arial'
FONTSIZE 12
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Left
END TEXT
BEGIN TEXT
EXPRESSION Date()
ROW 7
COL 177
WIDTH 30
HEIGHT 10
FONTNAME 'Arial'
FONTSIZE 12
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Left
END TEXT
END FOOTER
* Summary Band ************************************************
BEGIN SUMMARY
BANDHEIGHT 50
BEGIN TEXT
EXPRESSION 'Total Records: ' + Str(RecCount()) + chr(13) + 'Total Pages: ' + Str(_PAGENO)
ROW 10
COL 20
WIDTH 60
HEIGHT 30
FONTNAME 'Arial'
FONTSIZE 12
FONTBOLD .T.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Left
END TEXT
END SUMMARY
* Group Definition *********************************************
BEGIN GROUP
GROUPEXPRESSION Test->product
BEGIN GROUPHEADER
BANDHEIGHT 15
BEGIN TEXT
EXPRESSION Test->product
ROW 5
COL 20
WIDTH 100
HEIGHT 30
FONTNAME 'Arial'
FONTSIZE 14
FONTBOLD .T.
END TEXT
END GROUPHEADER
BEGIN GROUPFOOTER
BANDHEIGHT 15
BEGIN TEXT
BEGIN TEXT
EXPRESSION 'BALANCE:'
ROW 5
COL 20
WIDTH 100
HEIGHT 30
FONTNAME 'Arial'
FONTSIZE 12
FONTBOLD .F.
END TEXT
//****************************** ADDED
BEGIN TEXT
EXPRESSION mbal
ROW 5
COL 70
WIDTH 600
HEIGHT 10
FONTNAME 'Arial'
FONTSIZE 9
FONTBOLD .F.
END TEXT
//********************************* TO HERE
BEGIN LINE
FROMROW 11
FROMCOL 50
TOROW 11
TOCOL 160
PENWIDTH 0.1
PENCOLOR { 0 , 0 , 0 }
END LINE
END GROUPFOOTER
END GROUP
END REPORT
Return
FUNCTION FLS // creates temp file
local aDbf := {}
aadd(adbf, {"item", "c", 10, 0})
aadd(adbf, {"product", "c", 10, 0})
aadd(adbf, {"rate", "n", 8, 2})
aadd(adbf, {"balance", "n", 8,2})
if !hb_dbcreatetemp("test", adbf)
msgbox("Cannot create temporary table: Item")
RELEASE WINDOW ALL
return nil
endif
if select("test") = 0
use test new
endif
select test
append blank
test->item := "CD1"
test->product := "Compact1"
test->rate := 1.00
test->balance := 3.00
unlock
append blank
test->item := "CD2"
test->product := "Compact1"
test->rate := 2.00
test->balance := 3.00
unlock
append blank
test->item := "CD3"
test->product := "Compact2"
test->rate := 3.00
test->balance := 7.00
unlock
append blank
test->item := "CD4"
test->product := "Compact2"
test->rate := 4.00
test->balance := 7.00
unlock
append blank
test->item := "CD5"
test->product := "Compact3"
test->rate := 5.00
test->balance := 11.00
unlock
append blank
test->item := "CD6"
test->product := "Compact3"
test->rate := 6.00
test->balance := 11.00
unlock
index on product to test
RETURN
//**************************** ADDED THIS FUNCTION
function advan
local mcu
mcu := product
mbal := 0
skip 1
if product <> mcu
skip -1
mbal := balance // all mem variable can be created here
skip 1
endif
if eof()
endsec := .T.
endif
return