How to print a report when no records are involved (131200)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro for Windows 7.0
  • Microsoft Visual FoxPro 8.0
  • Microsoft Visual FoxPro 9.0 Professional Edition

This article was previously published under Q131200

SUMMARY

The REPORT FORM command requires an open table or cursor with at least one record, otherwise it doesn't print anything. This article shows how to work around this.

MORE INFORMATION

If you have set up a report to print the results of a SQL statement sent to a cursor and that query returns zero (0) rows, the report doesn't print.

The following code shows by example how to print the report even if zero rows are returned. It is valid for a report named TEST.FRX that contains three fields: fname, lname, and dob (date of birth). The CREATE CURSOR command must create a field for each field in your report.
   IF _TALLY=0
      CREATE CURSOR Temp (fname c(30),lname c(30),dob d)
      INSERT INTO Temp (fname) VALUES ('Nothing to print')
   ENDIF
   REPORT FORM TEST.FRX NOEJECT NOCONSOLE TO PRINTER
				

Modification Type:MajorLast Reviewed:2/11/2005
Keywords:KB131200