Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Print

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

It is basically in Continuation of my previous thread of [highlight #FCE94F]how to add column[/highlight].

Kindly let me know how to print these fields in report as these fields are not permanent.
The Structures are as follows:

myr1 = 'Y_'+mYear &&mYear = 2016
myr2 = 'Y_'+ALLTRIM(STR(mYear1))
myr3 = 'Y_'+ALLTRIM(STR(mYear2))
myr4 = 'Y_'+ALLTRIM(STR(mYear3))
myr5 = 'Y_'+ALLTRIM(STR(mYear4))
myr6 = 'Y_'+ALLTRIM(STR(mYear5))

Crea Curs katsale (location c(30),;
&mYr1 n(13,2),;
&mYr2 n(13,2),;
&mYr3 n(13,2),;
&mYr4 n(13,2),;
&mYr5 n(13,2),;
&mYr6 n(13,2),;
pcode c(10))
Index Tag Location On Location
reperr1_apjmq9.png

Thanks

Saif
reperr_tq65yb.png
 
Well,

what you tried so far is &myr1, correct? The name of the column is in that variable, so that would work as expression. Doesn't it?
The descriptions captions must either be ALLTRIM(STR(mYear1)), etc as you did use for putting together the names, or just plain mYear, mYear1, mYear2,... as expression. You can't have a label report control there, this also has to be a field control with expression, not just a label with it's caption, the caption will always be printerd 1:1 as is and not evaluated as the expression of a field control.

Bye, Olaf.



 
Thanks for the explanations. I am sorry I couldn't understand this.
What I understood is to put the express like:

'Y_'+ALLTRIM(STR(mYear1)) in Expression Box.

Please suggest me.

Thanks

Saif
 
Assuming Katsale is in the selected work area when you run the report, you could put FIELD(2), FIELD(3), etc. as your column headings (they would have to be report fields [that is, expressions], not labels). FIELD(2) will evaluate to the name of your second field (Y_2016), and so on.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike,

Please compare the data which I want to show in output. I tried whatever I understood, I think something is missing to understand.

Saif
rep1_o12lze.png
rep2_m0sffl.png
 
It looks like your column headings are now correct, but not the body of the report.

I'm not sure why you are getting [tt]Y,201,[/tt] in the detail band. But the macro ([tt]&myr1[/tt]) won't work there, because the report doesn't know the contents of the variables (myr1, etc.) ar report-printing time.

Try putting [tt]EVAL(FIELD(2))[/tt] etc in the details band.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Looks to me like he is getting a string (Y_2016) formatted as a currency Y,201,

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
A completely different - and simpler - approach:

Use hard-coded field names in your cursor. Call the fields, say, Year1, Year2, etc.

When you create the report, use those same field names in the detail band. No need for macros, etc as the field names will always be the same.

That just leaves the issue of the column headers. Assuming that they follow the pattern in your screen shot, you could set the headers to YEAR(DATE()) - 1, YEAR(DATE()) - 2, etc.

Just a thought.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
>'Y_'+ALLTRIM(STR(mYear1)) in Expression Box.
No, I said you put mYear1, mYear2 etc in fields to get the captions 2016,2017,...

And in the detail band you need to put [tt]&mYr1[/tt] as you already did. [tt]EVAL(mYr1)[/tt] would be an alternative.
Again you need report fields, not report label controls.

Griff might spot something important, too. You must remove any formatting first, then later might decide what formatting to do on the printed values, but first see what you print unmodified by formattings. If all else fails add a new report field to start from scratch, just for a single column for testing.

Be more open to experimenting. Everytime you only read data, no real harm can be done. Save the frx as a new report and then change and you can always revert to the initial report layout.

Bye, Olaf.
 
Bravo!!!!

It is the perfect result which I was looking for.

Thanks for the time sharing for this.

Saif
rep3_t9oltr.png
 
Based on what you seem to be trying to report on and what you showed as your code in your other post ([highlight #FCE94F]how to add column[/highlight]) your first problem seems to be in how you are grouping your data Totals

In your previous post you show: group By theyear,location ;
But looking at your reports above, you seem to want to show the values for each location for each separate year.
If that is correct, you would want to use: group by location, theyear
Then for printing your report, you would want to copy the values from that Location's year values into the new Year-specific field that you Added.

I'd suggest that before you issue your REPORT FORM command, you use a SET STEP ON command or set a Breakpoint to suspend the code execution. Then Brose the data table/cursor that you are going to send to the Report Form so as to ensure that the data is how and where you expect it to be.

Then, after all of that is working, you can work on how to get your Report Form to show it.

Good Luck,
JRB-Bldr





 
Thanks for the suggestions. I will look into it.

Saif
 
Using the FIELD() function has the pro argument to work with any field names of fields 2,3,4,... and the con argument it'll stop working once you add more fields before the year fields than just the location field. You got to take that into account. When you don't have released the variables used to do the CREATE CURSOR, then EVAL() will also work with them as they are guaranteed to have the exact same names. The report is limited to work on that cursor anyway, so the stronger coupling with variables isn't that bad, though it's otherwise best to avoid too much dependencies this one means a guaranteed synchronisation of names used.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top