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

How to display message? 1

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
578
0
16
PH
Hi everyone... i have these codes

IF DTOC(Start) = " / / "
REPORT FORM TransReport FOR Details.TransCode = tipis TO PRINTER PROMPT PREVIEW
ELSE
REPORT FORM TransReport FOR Details.TransCode = tipis AND SUBSTR(DTOC(details.deyt),1,10) => DTOC(start) ;
AND SUBSTR(DTOC(details.deyt),1,10) =< DTOC(ind) TO PRINTER PROMPT PREVIEW

ENDIF

its working fine... but i want to put a message when nothing meets the criteria or nothing is to be displayed... How would i do it? Please help... Thanks...
 
Mandy,

You can do this by checking the cursor that drives the report. For example:

Code:
IF EMPTY(Start)
  SELECT * FOM Details WHERE Details.TransCode = tipis INTO CURSOR csrDetails
ELSE 
  SELECT * FOM Details WHERE TransCode = tipis AND SUBSTR(DTOC(details.deyt),1,10) => DTOC(start) ;
     INTO CURSOR csrDetails
ENDIF
IF RECCOUNT("csrDetails") = 0
  MESSAGEBOX"No data for this report")
ELSE
  SELECT csrDetails
  REPORT FORM TransReport PRINTER PROMPT PREVIEW
ENDIF

The only snag is that, if the field names in your report includes the alias, you will have to change that (from Details to csrDetails). For example, if the report includes the Start field, and it is specified in the report has Details.Start, you will have to change that to csrDetails.Start.

If you are already creating a cursor to drive the report (in other words, if Details is itself a cursor), then you can simply add the above WHERE clause to the SELECT that creates the cursor. In that case, you won't need to change the actual report.

By the way, you will see that I have changed your [tt]IF DTOC(Start) = " / / "[/tt] to [tt]IF EMPTY(Start)[/tt]. This is preferable, as it doesn't rely on any particular settings for DATE, CENTURY, etc. The same applies to your [tt]SUBSTR(DTOC(details.deyt),1,10) => DTOC(start)[/tt], but I didn't alter that because I don't know the format of your Deyt field.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I've just realised there is a slightly easier way:
Code:
SELECT Details
IF EMPTY(Start)
  COUNT FOR Details.TransCode = tipis TO lnCount
ELSE 
  COUNT FOR TransCode = tipis AND SUBSTR(DTOC(details.deyt),1,10) => DTOC(start) TO lnCount
ENDIF

IF lnCount = 0
  MESSAGEBOX"No data for this report")
ELSE
  * Paste your original code here to run the report
ENDIF

Note only will this be slightly faster than my previous code, it means you will not need to change the actual report in any way.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you so much Mike... for helping me always.... and very comprehensive explanation.... Yes i will try those suggestions... God bless...
 
Hi Mike My app is now working perfectly displaying message no records to show if it did not meet criteria.. Thank you so much Mike...!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top