ON ESCAPE lCancelled = .T.because that will prevent the escape from stopping the query. You could have your error trap set lCancelled to .T. when it detects error 1839.
>cSaveErr = ON("ERROR") >SET ESCAPE ON >SET TALK ON >SET NOTIFY ON >ON ESCAPE lCancelled = .T. >ON ERROR lError = .T. >>
>SET TALK OFF >SET NOTIFY OFF >SET ESCAPE OFF >ON ERROR &cSaveErr > >IF lCancelled > MESSAGEBOX("Query cancelled by user",64, .Caption) >ENDIF > >>