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

Foxpro 8 - Report Form print only last record. 1

Status
Not open for further replies.

AlexBromo

Programmer
Jan 26, 2023
8
0
0
IT
Hello,

I create a simple report form with a 20 rows table placed in the data environment, the problem is that when I execute the report form instead to print 20 pages (one for every table row) it prints only the last record; the command I use is:

REPORT FORM <formname> ALL

adding other clauses like "PREVIEW", "TO PRINTER" etc ... nothing changes.

ALex.
 
why not remove the table from the forms data environment, but open it before your call to REPORT FORM having positioned on the first record?

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 is no place like G28 X0 Y0 Z0
 
Welcome to the forum.

When faced with this kind of problem, the obvious first step is to determine whether the fault lies in the data or in the report. So, I suggest you first follow Griff's advice, that is, remove the table from the data environment. Instead, open it explicitly (for example, with USE) in your program, immediately before your REPORT FORM. Make sure the corresponding work area is selected, and that the table is positioned at the first record (in fact, that last point is probably not necessary as you are using the ALL keyword, but you might as well be sure).

Now, suspend the program (either with the SUSPEND command or by setting a breakpoint) immediately before the REPORT FORM. Then take a look at the table to check that it contains the data that you expect.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you, that could be the solution ?

However I don’t know why it acting like this.

ALex.
 
You explicitly user ALL, which is the default. But what else could limit the number of records to be printed?

Either the report does have a private datasession it uses to determine its data, then trying to control it from outside can be futile. Or the other universal thing that reduces which records are processed is active: A filter. Ever thought about that? If you SET FILTER TO something and specify ALL, that still means only ALL to which the currently SET FILTER applies.

There also is a general solution to look deeper into any problem: The debugger.

Set a breakpoint right before or AT the REPORT FORM command, and then browse the table, look what filter is set with SET('FILTER'), look what runs, if you actually then execute the REPORT FORM, is there code in the report? The report also has methods and events because of the data environment it has. In the end that can go as far as that it is using a completely different DBF than you think it will.

Chriss
 
One other thing to look for - in the report - is any Print When settings.

But before going any further, in will help to know if you are seeing the correct data in the table immediately before you execute REPORT FORM.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
This is a well known problem. If there's a grid on the form from which you start the report, make sure than another object on the form gets focus before the report is run.
 
Tore,

I also thought this might be caused by the grid problem that you mentioned. But, as far as I remember, the effect of that problem is that all the data appears in report preview, but no data appears when you print. That's not exactly what Alex is seeing. In his case, he always sees one record, and there is no difference between previewing and printing.

Still, it's worth considering this as the cause of the problem. So, Alex, are you in fact launching the report at a point when a grid has focus? If so, follow Tore's advice.

For more information about this problem, see VFP reports not showing the same data as the preview.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you so much for help.

I have a simple table called "huambo1.dbf" (no indexed) with 30 records and a report called "huambo2.frx/frt", the report's page represent a table's row and every field in the report is specified as "huambo1.<fieldname>".

Ok, I proceeded as suggested: I removed the "huambo1.dbf" form the report's data environment (now the report's data environment is empty)and wrote the simple program as below:

Code:
CD c:\sviluppo\huambo
SET DEFAULT to c:\sviluppo\huambo
CLOSE TABLES ALL 
USE huambo1.dbf
SUSPEND
REPORT FORM c:\sviluppo\huambo\huambo2.frx ALL TO PRINTER

I run the program and after suspended browsing the table I notice that the cursor is at first record (IMG 007)

bof_z8hh1b.jpg



then I RESUME and the report create the output PDF that unfortunately contains only one page containing the last record's data (GEW2 016)

Clipboard01_lp0ibi.jpg


[sad]

ALex.
 
Check your data environment for the report

Look at the init method, perhaps there is an instruction to move the record pointer


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 is no place like G28 X0 Y0 Z0
 
Update: I generate a new simple generic report using Report Wizard and it don’t seem to have that problem (it starts showing all records from the first); the only difference is that the fields on new report are noted as <fieldname>, not as <tablename.fieldname> as the non-functioning report.

Fearing in a VFP8 bug I also installed VFP6 but the problem persist.

ALex.
 
griff_d1yq1o.jpg


Griff, as told the report's Data Environment is empty.

ALex.
 
I'm stupid ... [sad]

I placed the report's body in the "Page header" section instead the "Detail Section" !!!

Now I moved all content in the "Detail Section" and all it seems running fine.

ALex.
 
Good to hear that you have solved the problem, Alex, and thanks for letting us know. Be sure to come back if you have any further questions.

By the way, I recommend that you upgrade to VFP 9.0 if at all possible.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Clipboard01_uptdst.jpg


Thank you all for suggestions !

A question: how to upgrade to VFP9, since the product is discontinued ?

ALex.
 
how to upgrade to VFP9, since the product is discontinued ?

There is no longer an official upgrade path, and Microsoft no longer sells VFP.

It's sometimes possible to buy VFP 9.0 on the likes of eBay. Just be sure that it is a legitimate shrink-wrapped product, with an installation key, not a pirated copy.

I'm not sure if this is still the case, but VFP is also included with a subscription to MSDN. Obviously that would be a more expensive option, but then again you do get a great deal more with MSDN than just VFP.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top