Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Report Data Sources
Message
From
09/08/2000 05:06:38
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
08/08/2000 19:06:47
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00402581
Message ID:
00402681
Views:
8
>I am relatively new to database programming and need to know how to make a reports work in FoxPro. I have a table with a date field and an amount field. My goal is to create a report that will let me select a date range and print the total number of records and a sum of the amount fields for EACH DAY within that range.
>
>I was thinkin about using a Select - SQL statement to retrieve the information into a temporary cursor and then work with it from there using report variables.
>
>Am I on the right track?


Almost absolutely you're on right track. Report variables not needed though. Just do your SQL with an ordering on date and use grouping in SQL or in report :

1) SQL grouping - You only get summary info :
lparameters tdStart, tdEnd
select dDate, cnt(*) as 'RecordCnt', sum(Amount) as 'SumAmount' ;
 from myTable ;
 where dDate between tdStart and tdEnd ;
 group by 1 ;
 into cursor crsReport && Group by does an implicit order by
create myReport from alias() column
modi report myReport

2) Report grouping - You get all detail and have option to run report with 'summary' clause :
lparameters tdStart, tdEnd
select dDate, Amount ;
 from myTable ;
 where dDate between tdStart and tdEnd ;
 order by 1 ;
 into cursor crsReport 
create myReport from alias() column
modi report myReport
Here in report you would create a grouping on dDate and in group footer would place two fields :
a) dDate with calculation count
b) Amount with calculation sum
Both reset per dDate change.
A 3rd field in group footer makes sense to show dDate.

In both approaches these same fields in Summary band (with reset at end of report) provide a Grand total.

In approach 2 you have the option of showing detail in detal band if you wish (actually you would get that route for you wish) and for 'summary only' reports could use 'summay' clause of report.

Also you can just use the tdStart and tdEnd values or any other memory variable defined in this routine (even if declared local) directly in report. ie: This is a legal expression that you can use in a field that you put in report Title :

'Count and Sum per Date from '+dtoc(tdStart)+' to '+dtoc(tdEnd)

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform