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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting a report variable 2

Status
Not open for further replies.

joebloeonthego

Technical User
Mar 7, 2003
212
CA
Is there a way to manually set the value of a report variable (custom variable)? I can't figure it out. I'd like to just assign it a value of zero if anything.

The problem:
I have a report with grouping on partnumber, and for each partnumber, there is a header, detail bands, and a footer. I'd like the pageheader to display 'continued from last page' if we're half-way through a partnumber (rather than just reprint the header on the new page).

My problem:
It keeps printing 'continued..' on the pageheader even when starting a fresh partnumber. The 'reset on partnumber' isn't working because it isn't reset yet. So I have a variable '_overflow' that I can count/sum whatever but I'd like to reset it to zero when the group footer prints. Is this possible?

ps - what may be complicating matters is that I'm stuck with the data I'm getting out of the program, but I'm making it report a totally different way by using some counting variables, and a lot of 'print when' stuff. and because of this I'm printing the header (with no partnumber specific info), possibly ignoring 1 to many partnumbers, then printing the footer with all the header info you'd expect for the partnumber. Make any sense? I doubt it.. :)
 
joebloeonthego,

From what I understood of the problem is that you would like to reset your variable after the footer is printed.

Simple, double click on the footer band ( Or from meny Report -> Bands... -> select your band and click Ok ) . And you will see a dialog Run Expression - on entry & on exit. You can even call a procedure and do run 1000 lines of code if you want. And the variables declared in report are public by default so you can use them in the procedure too. Or you can simply change the value of the variable w/o calling any procedure. I hope it helps.

 
joebloeonthego

If you create your variable within the report (Report->Variables), from the you can set the initial value, the default value, and you can indicate at what point it gets reset (At the bottom), you can set it to reset every pages.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
nirajjobanputra: That's exactly where I'd like to reset it.. the question is how do I do it? The help makes no mention of assigning a value to a report variable. The '=' is logical, so that's not it. I'm just wondering what the syntax is for making such an assignment.

mike: I've done just that, the problem is that I need to trigger the reset myself (in the footer) because the report driven resets (on partnumber) or page will not work in this case. I want it to reset on every footer (only one group in the report).

And just to reiterate somewhat, I don't have access to any code, just the report.
 
HI

There are a number of ways to achieve this. One way could be..

To add the "continued from last page.." text to in the header band,

1. a. Add a new report variable named "nGroupLines".
b. Set the "Value to Store" to 1
c. Select the Count option
d. Set the variable to reset at the end of the Group.

2. In the Group Header band, add a new field control at the place where you want the 'continued.... ' text to appear. Use the following as the expression.....

IIF(nGroupLines = 0,'','continued from previous page...')

3. Make sure that to print the group heading on the top of each page, even if it isn't starting a new group, by checking the box that says, "Reprint group header on each page".

Now this should work. :)


ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
I have a report with grouping on partnumber, and for each partnumber, there is a header, detail bands, and a footer. I'd like the pageheader to display 'continued from last page' if we're half-way through a partnumber (rather than just reprint the header on the new page).

So, If you want to reset every footer why not use nirajjobanputra's suggestion and reset the variable in the footer band.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
ramini: This is _exactly_ what I've done. (well, my variable was called 'overflow' and I used 'print when <> 0' instead of the if statement :)
The problem is with the reset at group. It isn't actually resetting until after the header for the next group is printed. Therefore, even if the last group finished completely, it still prints on the top of the next page.

So I need to force a reset in the footer.
 
mike: that's just what I want to do. I just don't know how to change the value of the variable. I don't know the syntax for an assignment, and i couldn't find it in the help.
 
joebloeonthego

1. Modify your report.
2. Double-click on the footer band (the gray band) and click on the &quot;On exit&quot; button, and in the expression put :
overflow=0


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Oh yes Joe, I got your problem. This you cannot avoid in the natural flow order of the VFP report designer.

However, try the following.. and this could work..

IIF(overFlow>0,IIF(getNext(partNumber),&quot;Continued.&quot;,''),'')

Now, add the function getNext at the end of your Main.PRG
*************************************
FUNCTION getNext
PARAMETERS tPartNo
LOCAL lReturn
lReturn = .f.
IF ! EOF()
SKIP
IF ! EOF()
IF partNumber == tPartNo
lReturn = .t.
ENDIF
ENDIF
SKIP -1
ENDIF
RETURN lReturn
************************************
:)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
isn't a logical expression? returning .T. or .F.?
It must be because in the pageheader I have 'print when': _overflow <> 0.
And in the footer I have 'on exit': _overflow=0

and it still prints.

Also this was one of the first things I tried, except I had the expression in a field I stuck there just so I could run the expression, and it was printing .T./.F. on the report so I assume(d) that it was purely logical, and doesn't do the assignment.
Just to test, I stuck a _overflow field in the pageheader just now, and it is indeed showing the number of detail bands of the previous partnumber whether it finishes or not.
 
the previous response was to mike, sry..

ramani: I don't think I have access to a main.prg. I can't access any code, I can only modify the report. (frt and frx)

It's not mission critical that I have 'continued..' print (so I don't want to waste too much of anyone's time), I just thought there would be a way to assign a value to a report variable (and this would've been good to know for any number of future reports), or a way to trick foxpro into assigning it for me when I wanted it too. :)
 
One thing I would like to add here is.. That I have noticed the variables are recalculated even while you are on the same page and you zoom in or zoom out.

I am sure there must be some way out of it. But I didnt care much about it before. However if somebody knows the solution I would like to know.
 
Ramani:

I've designed hundreds of reports and never employed any group &quot;...continued&quot; idea. Thanks.

Al
 
Joe,

Since you only have access to the report, can you move the &quot;Page Header&quot; into &quot;Group Header&quot; ? If you can, it will solve your problem

Regards

-- AirCon --
 
aircon: thanx, but I tried that too. The pn doesn't seem to be reset yet, even in the group header (which to me doesn't really make sense). But that wouldn't really work anyways, or else it would print all the time, not only on a pagebreak, in which case I'd need a variable to mark the pagebreak and.... :)
 
Joe,

I don't know of the other problems you have. I had a working example. But I'm not sure if it is what your looking for. If you want I can send it to you

Regards

-- AirCon --
 
Hi Joe,

It is not necessary that you need access to Main.PRg. You can create the getNext as a Prg without the first line.. i.e. save the following as getNext.PRG Then the rest of my codeing will be same. Save this PRG in the directory where the report is kept.
***************************************
** FUNCTION getNext
PARAMETERS tPartNo
LOCAL lReturn
lReturn = .f.
IF ! EOF()
SKIP
IF ! EOF()
IF partNumber == tPartNo
lReturn = .t.
ENDIF
ENDIF
SKIP -1
ENDIF
RETURN lReturn
************************************

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Joe,

I just reread all the solution above. Actually the first solution from Ramani's does worked. The variable does reset.
I tried that. Can't figured why it doesn't work for you

Notes: just in case you did not noticed it also use a &quot;Group Header&quot;


-- AirCon --
 
ramani: I didn't know I could write functions, this could open a lot of doors....

One problem though, when trying it out (in preview and to printer), when I go to page two (or when it starts to print page 2), I get an error that 'table buffering is not enabled'.

I assume this is a show-stopper. If nothing else I learnt how to use functions in my reports! thanx!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top