At 08:51 AM 12/18/2015, Hodges, Dennis wrote:

In the following print command if the where command returns no records, the value
of holder is 0, but I get a 2059 error message.  How can I trap this error?

SET ERROR VARIABLE verrvar
  PRINT needfile ORDER BY site WHERE datecomp IS NULL AND ((crew1 = .zcrew) +
  OR (crew2 = .zcrew) +
  OR (crew3 = .zcrew) +
  OR (crew4 = .zcrew)) +
  OPTION SCREEN|WINDOW_STATE MAXIMIZED +
  |ZOOM_TYPE percentage 98
  set var holderr = .verrvar


Dennis,

Here is the best approach to handle such circumstances ...

-- Start here ...
SET VAR vRows INTEGER = 0
SELECT COUNT(*) INTO vRows INDIC iv1 FROM reporttablename +
WHERE datecomp IS NULL AND ((crew1 = .zcrew) +
  OR (crew2 = .zcrew) +
  OR (crew3 = .zcrew) +
  OR (crew4 = .zcrew))
IF vRows = 0 THEN
   CLS
   PAUSE 2 USING 'No qualifying records to print this report' +
   CAPTION 'Print Report' ICON WARNING +
   BUTTON 'Press any key to continue ...' +
   OPTION BACK_COLOR WHITE +
   |MESSAGE_FONT_NAME Tahoma +
   |MESSAGE_FONT_COLOR RED +
   |MESSAGE_FONT_SIZE 11
   GOTO Done
ENDIF
  CLS
  PRINT needfile ORDER BY site WHERE datecomp IS NULL AND ((crew1 = .zcrew) +
  OR (crew2 = .zcrew) +
  OR (crew3 = .zcrew) +
  OR (crew4 = .zcrew)) +
  OPTION SCREEN|WINDOW_STATE MAXIMIZED +
  |ZOOM_TYPE percentage 98
LABEL Done
  CLS
  CLEAR VARIABLES iv%,vRows
  RETURN
-- End here ...

Hope that helps!

Very Best R:egards,

Razzak

Reply via email to