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!

Report with empty table

Status
Not open for further replies.

Mimmo M.

Programmer
Sep 17, 2000
8
IT
Hello,
I'm using VFP 9 sp1 and I've a simply problem that I can not solve.
If I try to run a report, it is not printed if it is not open a table with at least one record.
Could you help me understand how to do it please?
Many thanks!
 
This behaviour is by design and has always been this way as far as I can look back to VFP6. If you have nothing to print, nothing is printed. That's also true if you REPORT FORM some.frx FOR somecondition and no record matches the condition.

So first determine the count of records you would report and if that's 0, simply inform the user nothing can be reported.

Bye, Olaf.
 
Olaf said:
This behaviour is by design and has always been this way as far as I can look back to VFP6.

It's actually core behavior of the language going back AT LEAST as far as dBase III. (And probably dBase II.)

REPORT FORM is a scoped command. If no records fall in the command's scope, there's nothing to do. This is the same reason the mysterious (not!) "replace while at end of file" thing happens. Or ... err ... doesn't happen.

It all boils down to understanding how commands are scoped.

If you REPLACE FOR <expr> and nothing qualifies for <expr>, then nothing happens. FOR <expr> is the command's scope. There wasn't anything in the command's scope to do, so nothing gets done.

It's actually sorta important to understand how commands are scoped (and how/where that scope is evaluated).
 
And that even applies, if your report has no bound controls or you only bind to variables or function calls, or eg only want to print an empty form. A report has a main workarea driving it and that has to have minimum 1 record in scope. The problematic case is a report with dataenvironment, which determines it's data by being run and not beforehand. But even in that case, you can check the count in DE code section and inform the user.

Bye, Olaf.
 
What I usually do is test for [tt]RECCOUNT = 0[/tt] before running the report. If there are no records, display a "no data" message to the user on the screen. I think that's a better user interface than if an "empty" report was printed. But if you really want to actually print a page with headings but no data, insert a dummy blank record into the cursor, then delete it afterwards.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Users sometimes DO want to print an empty report.

This bit me almost 30 years ago in a data collection app. We over-tested and always ran reports after data entry. In that particular app, I created tables at the start of data entry. When users wanted to see the empty format of the reports before data entry the tables didn't exist yet. Boom.

My earlier comments were merely to explain the why. There are plenty of ways to get the deed done once the why is understood.
 
Dan said:
Users sometimes DO want to print an empty report.

Yes, I agree. That's why I mentioned the option of inserting a dummy record.

There must be many commercial situations where this applies. For example, a credit control department might print a weekly list of overdue invoices. If there are no overdue invoices in a given week, it might still want a printed record of that fact. So it would be appropriate to pint a single page with the standards headings etc. in place, but no detail records.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
A credit department is a good example.

I recently noticed some of our own reports for the credit department did nothing if no records were in scope. I asked the credit manager if that was ever an issue. She said "we never have a week where nobody is behind in payments". <sigh>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top