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

Trouble with a Report form

Status
Not open for further replies.

johann59

Programmer
Mar 3, 2005
32
US
I'm trying to have my Program (form) create a text file from a report form and I'm having some issues. I'm using VFP 8 and this is the code inside a command button:

REPORT FORM C:\Jobs\Reports\Report.frx NOEJECT NOCONSOLE TO FILE C:\Jobs\Reports\RPT0419.txt ASCII

a) When I execute the command it does run the report and creates a file but it comes up empty. 0 bytes. I'm able to preview it, with the exception of the fields I want it to display, but I can preview it, but I execute the command it creates an empty file.

b) Another issue is that after executing the command to create the report, the Open Dialog box just keeps popping up, even though I press Cancel, it just keeps coming up until I'm forced to close VFP with CRTL+ALT+DEL. It just seems it wants me to create a file. I've also tried that but the Open Dialog box still keeps popping up.

c) I have in the report 3 tables I added to the Data Environment. How to I get a field to print the RECCOUNT() from a particular table. I thought about using inside the Expression box the following: -Table1.RECCOUNT(); -Table2.RECCOUNT(); etc. in each of the fields, but it is not working. I want to print the count of each of the 3 tables and I want it on the report.

d) Last issue, how do I call a variable inside a field of the report? When I run my program, I writing to a variable the file name of the file I choose to run at that particular time and I want the report to have the file name in it and my thought was to carry it with a variable. I have no idea how to call a variable from a field on the report.

Have been trying to get this to work all weekend and have not been able to. The report is just a simple report, nothing fancy. All I have are some labels and the fields I want to use.

Any ideas? Thanks.
 
Have you tried running the Report Form to a Preview (not to a File) in the VFP development mode?

I have often found that when there is a missing or mis-named variable/field reference, the resultant form comes up blank.

In the Preview mode, this type of problem would show up by the Report Form throwing an error message indicating which variable/field it could not find.

If you have not done so, give it a try.

Good Luck,
JRB-Bldr
 
Yes, I have previewed the report, and it is not giving me any error, but when I go to execute the command the report comes up empty and the issue with the Open Dialog box happens, where I cannot Cancel the dialog box unless I quit VFP using the CTRL+ALT+DEL. Thanks.
 
Well if you have already checked the Report Form and its references with PREVIEW mode, then I am grasping at straws now.

Have you 'hacked' the Report Form FRX data table
REPLACE Expr WITH "", TAG WITH "", TAG2 WITH "" FOR RECNO() = 1
to eliminate any inherited Print Driver info?

Good Luck,
JRB-Bldr
 
I'm sorry I don't understand what you mean by 'hacked' the report form. Do you mean write that code inside the Expression box of the field?

Although you are giving me an idea that it might have to do with the inherited printer, because my default printer is set to create a PDF which automatically wants to open a file. That might be it.

But I still would like to know what you meant by 'hacked'. Thanks.
 
The way to 'hack' your VFP Report Form is to USE the FRX file.

Code:
cMyRptForm = "C:\Forms\MyRptForm.frx"

USE (cMyRptForm) IN 0 ALIAS RptForm && Report Form table

SELECT RptForm
REPLACE Expr WITH "",;
   Tag WITH "",;
   Tag2 WITH "";
   FOR RECNO() = 1
USE

This will clean out ALL 'inherited' printer settings.

Now if your report needed to be in Landscape mode, this might be a problem, since it would get rid of that too, so you would need to be somewhat more selective on what you left in the Expr field.

But since your Text file is not likely to be in Landscape mode, that should not be a problem.

NOTE - with the Report Form 'hacked' clean, the print out will use the workstation's default print driver. Even if you are outputting to a Text File, the default print driver might have some influence on it. But when the Report Form is cleaned out, you are more likely to have things work as you intend.

For test purposes, you might want to set the workstation default printer to something other than a PDF print driver.

If the workstation default printer in general needs to be the PDF print driver, then your VFP code can dynamically change this setting programatically to output the report and then set it back.

Good Luck,
JRB-Bldr
 
Hi Johann,

I'll have a shot at answering your questions:

a) ASCII text file is empty. One possibility is that you are looking at the file while VFP still has it open. In other words, VFP has written the contents, but has not closed the file, so the contents are not yet comnmitted. Try coming out of VFP completely before viewing the file.

Of course, that doesn't solve the problem, but it might give you a clue as to its cause.

b)Open dialogue keeps popping up. There must be something in your report that requires a table that isn't open and isn't in the data environment. Check every expression in the report to see if you can identify the table in question.

c) Displaying the record count. Table1.RECCOUNT() is bad syntax. It should be RECCOUNT("Table1") (not the double-quotes).

d) Passing a variable to the report. You need to declare the variable as PRIVATE in the calling program.

Hope this helps.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top