>>Hi,
>>
>>I am new to this forum and also to Visual FoxPro. I am trying to figure out how to run a query and output the information to a table or a report. This is what I need to do:
>>
>>Product Jan Feb Mar Apr May etc.
>>q1 12 0 3 8 12
>>w9 9 5 12 13 15
>>etc.
>>
>>Basically, I want to run a query that will tell me that I have sold X amount of product 1 in Jan, Feb, etc and continue to do that for all products. I am having trouble using the cross-tab query wizard. I cannot get the query to total the products by month. Any information you can provide will be greatly appreciated.
>>
>>Thank you,
>>
>>Jim Catanich
>
>Jim,
>
>I can help you get your totals. After your xtab query, try this:
>
> FOR lnCnt = 2 TO FCOUNT()
> lcFieldName = 'MyField.'+FIELD(lnCnt)
> CALCULATE SUM(&lcFieldName) TO lnSum
> GO BOTTOM
> REPLACE &lcFieldName WITH lnSum
> ENDFOR
>
>Worked like a charm for me!!
>
>HTH
Peryy,
Nice ! This would work but just before this routine do not forget to append one blank record.
Here is another approach which I find fast :
lparameters cXtabTableName
sum to array aSums
dimension aSums[alen(aSums)+1]
ains(aSums,1)
aSums[1]="Totals"
insert into (cXtabTableName) ;
from array aSums
Cetin