General information
Category:
Reports & Report designer
Claudio,
The best way to make a report is to SELECT into a cursor. If you select carefully, you will be able to use the same report layout for both ways of showing the data. Try this:
SELECT SalesMan AS MyGroup, ;
SUM(ValueSold) AS Amount ;
FROM MyTable ;
INTO CURSOR MyReportCursor ;
GROUP BY 1 ;
ORDER BY 1
lcMyHeading = "Salesman"
REPORT FORM MyReport PREVIEW
*!* REPORT FORM MyReport TO PRINTER PROMPT NOCONSOLE
SELECT Payment AS MyGroup, ;
SUM(ValueSold) AS Amount ;
FROM MyTable ;
INTO CURSOR MyReportCursor ;
GROUP BY 1 ;
ORDER BY 1
lcMyHeading = "Payment Type"
REPORT FORM MyReport PREVIEW
*!* REPORT FORM MyReport TO PRINTER PROMPT NOCONSOLE
In your report, do not reference the fields as MyReportCursor.MyGroup, but simply MyGroup. This will work just fine if MyReportCursor is the current work area when you print, which it should be. It will also allow you to run the report off of any cursor with the appropriate data, no matter what it's name is.
In the report's page header, put the column headers as lcMyHeading and "Amount". Please note that you always want the second column to be headed "Amount" where the heading of the first column will vary depending on which way have added your ValueSold together. There are other ways to pass in a particular value to the report, but this is simple and will work. When previewing from the command window you may need to type lcMyHeading = "Payment Type", as the value of this variable is otherwise only available when running the code.
You can copy the items from the detail line to the report's summary band. Change the control for MyGroup (where the salesman's name goes) to "Summary", in the Amount control, select "Calculations" and click "Sum". This will automatically the sum over all values from the detail lines.
I hope this gets you started. Repost with any problems.
>Hi, foxes!
>
>I have a table such like that below:
>
>SalesMan ValueSold Payment
>John 15,00 Check
>Joseph 10,00 Money
>Mary 12,00 Check
>Silvio 9,00 CredCard
>Paul 5,00 Check
>Joseph 20,00 Check
>Silvio 13,00 Money
>Joseph 18,00 Check
>
>
>What I need in my Report:
>
>SalesMan Value to Receive
>
>John 15,00
>Joseph 48,00
>Mary 12,00
>Silvio 22,00
>Paul 5,00
> -----------
>Summary 102,00
>
>
>And now, Payment's way summary
>
>Payment in Value
>CredCard 9,00
>Check 70,00
>Money 23,00
> -----------
>Summary 102,00
>
>
>Well, my report needs to give how much each salesman sold, and how
>much was sold in each type of payment (credicard, check, money, etc.)
>
>Does anybody can help me?
>
>Thanks in Advance
>
>"I'm using VFP 6 with SP 3"
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only