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

Reports. Can Summary Band be made optional at runtime?

Status
Not open for further replies.

GriffMG

Programmer
Mar 4, 2002
6,321
FR
I have a report where the customer would like a summary page - detailing a variable number of records (probably no more than 5/10 or so) but only if there are any records to show.

I can make the band, and make the contents visible only if there are details to show, but I get a blank page if there are none - not good because that is the same cost to them as a single (colour) photocopy and the customer would prefer not to waste paper.

I could make 2 reports, one with and one without the summary band, I could make a single report (which is what I have done for now) by joining two together (one which is just the summary band) at run-time using the NOPAGEEJECT option when there are details for the summary

I suppose I could even shove the .frx out to disk locally and hack it to remove the summary band at runtime...

But I just wondered if I was missing a trick, is there a way to programmatically make the summary band optional at runtime?

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.
 
Griff, I don't know of any trick that you might be missing. But I have to say that, if I had this requirement, I would almost certainly do what you are currently doing. I would make the summary into a separate report and decide at run time whether or not to run it (usinng NOPAGEEJECT for the main report if appropriate).

There may well be a more elegant approach. It would be interesting to see what other ideas people have.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
It does have the '1 to many' advantage - over using a true summary band.


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.
 
There's a SUMMARY keyword in the REPORT FORM command to suppress the printing of Detail Band lines and only print the Summary, but there doesn't seem to be an equivalent to do the opposite (only print the Detail Band lines and suppress the printing of the Summary Band).

So about the only way I would know to handle it (which you already suggested) would be to build your report with the Summary Band included. Then, if you want to suppress the printing of the Summary Band at runtime, make a temporary copy of the FRX on disk, open it as a table, and programmatically remove the Summary Band and any objects (labels, fields, shapes, etc.) contained therein prior to printing. After printing, you could delete the temporary copy of the FRX.
 
the .frx is really a .dbf so you could do something like

use fred.frx
select fred into cursor tmpfrx readwrite
&& by comparing 2 .frxs with and without summary i came up with this... but untested and no guarantees.
DELETE FOR objtype = 9 AND objcode =8
DELETE FOR objtype=7 AND objcode=4
use
report form tmpfrx


or

you might simply have 2 versions of the report in your program. one with and one without a summary ?

hth

nigel
 
Thank you Nigel

That was exactly what I was thinking when suggested I could 'even shove the .frx out to disk locally and hack it to remove the summary band at runtime...'



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.
 
Although I'm sure Nigel's solution would work, I'd personally be reluctant to use it. I'd be slightly nervous of any solution that depends on a knowledge of internal file structures. Of course, there is zero probability that Microsoft will ever change the structure, but I nevertheless have a built-in reluctance to rely on that fact. In general, I'd rather use doucmented features of the language where possible.

This is just my personal opinion of course. But it seems to me that the other solution - of creating two reports and chaining them with NOPAGEEJECT - would be simpler, more reliable and easier to maintain (in that other programmers looking at your code would be more likely to understand it).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike

I don't see much harm in using the hack solution, it can be documented and there is very little chance that VFP20 is on the horizon so it will probably work for the foreseeable.

I am awaiting feedback on the combined reports approach, it's been in place most of a week - but not used much yet.

One major surprise for me was how easy it was to use with XFRX, you just run each bit before the .Finalise() bingo. This mean my existing code was easy to change and, crucially, my feature which copies the output to the clipboard for pasting into e-mails works straight out of the box.

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.
 
Griff, I stress that my comments on not hacking the FRX were based on my personal views. Other people will take the opposite view, and that's fine. In fact, I have occasionally done FRX-hacking in my own applications, but only when I couldn't see an alternative solution.

It's interesting that you mentioned XFRX. I'd forgotten about the .Finalise() method. It's certainly an elegant feature.

Right now, I've got a requirement to generate a long report, and then to save each page of the report as a separate PDF with a filename that includes a member ID, and then to email each page to the corresponding member - all without human intervention. I'm sure XFRX will be a great help with this.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Err... Mike you do know it's GDPR day...

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.
 
Mike you do know it's GDPR day..

Do I know? I'll say. It's engraved in my consciousness. And probably that of many other people on Tek Tips as well.

But what's that got to do with hacking a report file?

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
You are skating on thin ice... not really, just having fun
Mike said:
and then to email each page to the corresponding member - all without human intervention.


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.
 
Don't worry, Griff. I'm covered every which way to Sunday. Explicit consent. Legitimate interest. Rigid data security. Notification of data breaches. All taken care of. I've even put 4% of my company's global turnover in a special account just in case.

(Only kidding abut the 4%.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I even believed the last bit.

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.
 
The major German newscast "Tagesschau" just reported fines can be 20 Million EUR or 4% of the global turnover, stating the 4% is for big companies. That makes it seem 20 Million EUR is the minimum. I think it's the other way <round, isn't it?

I don't yet collect any customer data online, but of course, I got a ton of emails, and most of them just point to their new privacy policies without asking you to confirm or accept them, I assume all those sites already complied to current laws anyway.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Olaf, the reason those emails don't ask you to confirm or reject the new privacy policies is that the firms in question have an underlying business reason to keep your data. They couldn't operate their businesses otherwise. So there's no question of your having the opportunity to opt in or opt out. By contrast, a firm that collects your data for marketing purposes must obtain your explicit consent. It is those firms that require you to update your mailing preferences.

For most people, this is all good news of course. It provides a very easy way of getting off all those mailing lists that you don't remember subscribing to.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, even those companies needing your consent and opt in, could already have asked for that long time ago, so they wouldn't need to now. In Germany the idea of opt-in vs opt-out was law for longer, already, for example. So no need to reask for that. Perhaps only to conform to certain new norms.

In contrast I got a form asking for my information from kickstarter, just my mail address and name, nothing critically like banking data. I thought that was a bit overdone.

I'm not that deep in that topic, as I have no work reference in the public web anyway, rather company internal applications. Yet, I indeed also got some things I had long forgotten about. Nothing really bad so far. I just read IT news about what you would have expected to surf that wave - sam sites asking you for credentials and other sensitive data.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Griff,
One other solution is to not use the report writer. This requires a lot more time in investment to recreate the report, but it can be done.
A very long time ago (We're talking more than 25 years ago now) when I was starting out in Fox 2.0, I wrote a report using HPGL direct to the printer (of course that means you are stuck with an HP printer), but it would print first to file, figure out how many lines it was, and then add white space into the report to make everything appear "balanced" on the page. (This was for a resume builder that I wrote for a University placement office, and that's the way they wanted it).

So the moral of the story here is... you don't have to use the VFP report writer, when it comes to doing something very custom, it can be done in code instead.


Best Regards,
Scott
MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Scott, I agree that there are alternative ways of producing reports, other than the VFP report writer. But talking directly to the printer via HPGL seems a very retrograde step. You identified one of the reasons for that yourself: being tied into a particular brand of hardware. In addition, you lose the benefits of a WYSIWYG design tool, there is no on-screen preview, and it is very difficult to fit text to a given space if you using a proportional font (which you almost certainly will want to do). Not to mention having to write a lot of code.

If we are considering alternatives to the VFP report writer, a better option might be Automation and Microsoft Word. You would still have to write a lot of code, and you still don't have the WYSIWYG design surface (but you do have the ability to view the report on the screen from within Word). But you do get all the flexibility and formatting options that Word gives you.

Another option would be to consider a third-party reporting tool. Crystal Reports can easily handle the situation that Griff is facing, and could probably solve many of the other reporting problems that people discuss in this forum (such as multiple detail bands) - albeit at the cost of purchasing the product and learning how to use it.

However, for the particular problem we are discussing here, I still think that chaining two reports together and using NOPAGEEJECT is the most satisfactory solution.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I loathe Crystal reports, albeit not had to touch it in a decade or more, just did not like it.
Bit like c# - some things just don't work in my 'clipper wired' brain.

Now writing in HP/PCL is not a problem, I do that everyday (almost), I have an aged Clipper (now Alaska xBase) app which generates all it's reports by writing HP/PCL.
Interestingly most commercial printers still have that at their hearts, so it turns out to be fairly portable - I use a bit of middleware called PageView to preview
all the reports and that works well.

With that approach (HP/PCL) you have complete and utter - to the pixel - control of your reporting, but by gum you need to have a mountain of resource to maintain it.




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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top