loWaitMessage = createobject("cWaitMessage", "Getting data...") loMessage = createobject("cMessage", "Getting data...") set escape on set notify on on escape plStop = YesNo("Are you sure you want to stop?") set talk on set talk window .ReallyLockScreen (.t.) if .oSearchCollection.requery() or .oBizObj.lNoRecordsSelected .ReallyLockScreen (.f.) if not m.plStop .nRecords = .oBizObj.nRecords loMessage.show("Your search produced " + transform(.nRecords) + " records. ") wait clear lcMessage = 'Records Found: ' + NumberCommas(.nRecords) if not m.plStop and .nRecords > 0 and reccount('c_Search') = 0 && Too many records if YesNo("Your search produced " + transform(.nRecords) + " records. " + CRLF + ; "It may take some time to display them." + CRLF + "Do you still want to proceed?") loWaitMessage.show ("Creating the final result... Please wait or press ESC to cancel") .ReallyLockScreen (.t.) .nRecords = .oBizObj.CreateFinalResult() .ReallyLockScreen (.f.) else lcMessage = "Too many records to display " + "(" + ; NumberCommas(.nRecords) + ")" endif endif if .nRecords = 0 or reccount(.grdSearch.recordsource) = 0 *------------------------------------ *--- No records found. Disable the *--- grid and the Select button *------------------------------------ .cmdSelect.enabled = .f. .grdSearch.enabled = .f. if not m.plStop and .nRecords = 0 MsgSvc('ErrorMsgDisplayValueOfVariable',.cNoRecordsMsg) lcMessage = 'No records to display' endif .SetFocusToFirst(thisform) else *--------------------------------------- *--- Records found. Enable the grid *--- and the Select button. Set focus *--- to the grid *--------------------------------------- goto top .cmdSelect.enabled = .t. .cmdCancel.enabled = .t. .grdSearch.enabled = .t. .grdSearch.setfocus() lcMessage = 'Records Found: ' + NumberCommas(.nRecords) .grdSearch.highlightstyle = 2 .cmdCancel.caption = "\<Clear" && It's not clear, not cancel endif .ReallyLockScreen (.f.) endif else ** Something went wrong endif if m.plStop .ReallyLockScreen (.f.) =ErrorMsg ('Search was cancelled!') lcMessage = 'Search was cancelled ' endif endif .WaitMode(.f.) if m.plStop && Search was cancelled, clear the results .oBizObj.EmptySearchResult() endif .grdSearch.refresh() release loMessage, loWaitMessage .ChangeFormTitle(m.lcMessage) set message to .caption .cls() endwith plStop = .f. * Now restore our settings on escape &lcOnEscape if m.lcSetEscape = "OFF" set escape off endif if m.lcSetNotify = "OFF" set notify off endif if m.lcSetTalk = "OFF" set talk off endifWhen I'm running Search, I can press ESC and the question is asked "Do you want to stop?" If I answer no, I re-execute the SQL.