Implement each page print specified record number in the VFP report
VFP has a wide range of applications in various enterprise institutions, I use it to develop the components used by this unit, and now is an indispensable management tool in this unit's daily work. There are many experiences in development, but I want to talk to everyone is to implement each page print specified record number in the report.
In the VFP's report generator, the report is prepared, and the recording data to be printed per page is controlled by adjusting the report page headband and the footer belt height. This is a relatively simple, easy implementation method. However, due to different computers, the default paper size is different, or the margins in the same paper type are different, the number of records per page is changed. This has no problem for fixed users and fixed printers, paper, but if the software is running on multiple computers or promoted to a wider user, consider different printers and paper issues. At this time, you can implement the method II and method three described below.
In addition, many users are required to fill the reports in the last page when the number of records in the table is not a single page, and only in the following methods can be implemented in the following methods.
In the following process, it is assumed that the table name used in the report is labels.dbf
In the report designer:
1. Remove all the alias prefixes in front of the print field in the report.
2. Remove the original table in the report data environment from the data environment.
3. Put the following code in the initial data of the report of the report:
* - DetailNum is the number of records to print in the detail tape, which can enter the modification here
Num = 10
* - The following SQL statement eliminates the impact of deleting records for packet fields and proper sorting of data
Select * from labels Into Table Temp Where not deleted () &&&& sgroupsby sort condition
SELECT INT ((Recno () - 1) / Detailnum) as groupcount, *;
Use in Temp
* - To maintain a clean environment, delete the temporary transition meter that has just been established
Delete file temp.dbf
IF file ("temp.fpt"
Delete file temp.fpt
* - Note: You can set the value of DetailNum in the code above the number of records you want to print for each page.
* - You can also set the SGROUPSBY clause to sort the data in the first SQL SELECT.
4. Add a group in the report and set the packet expression to GroupCount (that is, the first field name in the second SQL SELECT statement above) and selects the check box from the new page from the new page.
5, run your report.
6, the final explanation is: Set the correct path before running the report so that VFP can find the table used by the report.
In this method, a global variable TOBEPRINT is defined. The value of the variable is the number of records to be printed per page. If this variable is not defined, the 15 records are printed using the default per page.
1. Temp.dbf is added to the report data environment.
2. Set the buffermodeOverride property in the data environment of the TEMP.DBF to 5.
3. Write in the Data Environment Property Destroy Event:
= TableRevert (.t.)
4. Write in the data environment properties init event:
If VARTYPE (TOBEPRINT) = "U" &&& If the global variable is not defined, it defines its default to 15
TOBEPRINT = 15
* - The following code is to print the blank line when the number of records to be printed is less than one page, print the blank line to fill the entire report page
Do While Recount ("Temp"% TOBEPRINT <> 0
5. Newly built two report variables in the report such as NCOUNT, NGROUP, and Variable NCOUNT's computing option group, select the count, write in the variable NGROUP to be stored:
IIF (ncount <> 0 and ncount% TOBEPRINT = 0, NGROUP 1, NGROUP)
6. Add a group in the report and set the packet expression to ngroup and select the check box from the new page from the new page.
7, use the following code to run the report:
* - To avoid repeated defined variable errors, release it first before defining global variables
* - Define global variables, the number of records to print per page is saved in this variable
* - Set up 10 records per page
TOBEPRINT = 10
* - Print our report
Report Form Temp Preview
Methodology two and methods
Both are the method of data packets to implement "print specified record number per page", add a empty record in the table, "The number of records in the table is not a single page number in the last page with an empty table Full report.
The difference is that the method 2 is to use a temporary table to solve the problem, and the packet information of the data is written in a temporary table. The method three is to solve the group problem using report variables, and the data packet is implemented with report variables.