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!

Test for Report Form working 3

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
I keep a log file of activity in my app.

I currently have these two entries in my rep_preview prg around the actual REPORT FORM command.

12:38:43 Here - before report
12:38:47 Here - after report

Can I somehow record the fact that the report preview displayed and then add an entry to the log between the above two lines?

Thanks

GenDev
 
So you want to detect the report actually being printed, as opposed to being displayed in the preview window. Is that right?

If so, one solution would be something like this:

Code:
FUNCTION Log_Printing

IF SYS(2040) = 2
  * Report is being printed

  * Write to log file here
ENDIF

Call the function from your report's header band.

Note that this will only work with recent versions of VFP. With earlier versions, you can test for WEXIST("Printing...") to detect if the report is being printed.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
I'm really chasing the elusive error that the report is not running on some PCs.

I want to be able to record in the log that has happened so that when the user sends the log to me I can see their environment.

See other thread of mine just posted.

Regards

GenDev
 
Gendev,

I understand your reasons for wanting to log the report.

I answered your question, based on the assumption that you wanted to log the printed version of the report, as opposed to the preview. Did you read my answer? If my assumption was wrong, please say so, so that I (or someone else) can give you a better one.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Mike,

I'm trying to troubleshoot the non - appearance of one of the report s - one is a subset of controls from the other ( larger one ). So I want to confirm that the user was able to see the preview ( before choosing to print the report.

Regards

GenDev
 
Good idea, Mike.
That works to me.

Typically the thing to look for is empty report data, if no data is to be printed, not even the static elements of a report (labels etc) arte printed.

So you can test with a report being driven by whatever active alias and run it with an empty table to simulate the situation with no preview, then add a record to simulat the normal case.

I did a simple report with nothing but a report field control on it in the page header. I put MESSAGEBOX("header field") as the expression.

Running the report with an empty cursor without data does not even trigger that header field to make the messagebox call.

If I add a record via APPEND BLANK, the preview displays and the messagebox is called.

You can call whatever else, eg a function logging the display of the report preview. It tricky, but works. Just let your function return an empty string (RETURN ""), or else you will have a .T. in the report at that field position.

Another thing, that helps detecting the case of report being called with no data: Define a report variable "ReportRun", set Initial Value to messagebox("reportvariable"), leave everything else at default, that means reset value based on Report and Calculation type none.

Now even if calling that report with an empty table or cursor as the active workarea, that report variable is inited.

Again, instead of the messagebox call you can make a log call, at this time logging, if the report was called. In a normal case you now will have two log entries, one from the report variable, when the report is called, and one right afterwards from the report header, when the preview shows.

If you only find one entry, then the report data was most probably empty. You can make the log call from the report variable Initial value expression log more info, eg current workarea ALIAS(), RECCOUNT() and other relevant data for analysis and debugging the problem.

Bye, Olaf.
 
As Olaf has says: Typically the thing to look for is empty report data

Are you testing for the presence of data BEFORE issuing the REPORT FORM command?

Maybe something like....
Code:
   SELECT MyRptData
   IF RECCOUNT() > 0
      GO TOP
      REPORT FORM MyReport <whatever>
   ELSE
      WAIT WINDOW "No Data To Report!" TIMEOUT 5
   ENDIF
or
Code:
   SELECT MyRptData
   COUNT TO nRptRecs FOR !EMPTY(Field1)
   IF nRptRecs > 0
      GO TOP
      REPORT FORM MyReport <whatever>
   ELSE
      WAIT WINDOW "No Data To Report!" TIMEOUT 5
   ENDIF

Or, instead of (or in addition to) using the WAIT WINDOW, write to your log.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top