************************** FUNCTION RunSQL ************************** lparameters cSQL, canEsc, cWaitMsg, isMsg local ok * cSQL The complete query string * canEsc If .T. the user can press escape to abort the query * cWaitMsg [opt] can replace the defailt 'Running Query' display * isMsg If .T. the query string will display to the developer * and you can choose not to run the query! * RETURNS .F. if query aborted * be careful not to affect _TALLY in this procedure other than with the SQL result ok= .T. IF oG.develop AND m.isMsg local cStr cStr= STRTRAN(m.cSQL, ' from ', k_CR + k_TAB + 'from ') cStr= STRTRAN(m.cStr, ' where ', k_CR + k_TAB + 'where ') cStr= STRTRAN(m.cStr, ' and ', k_CR + k_TAB + 'and ') cStr= STRTRAN(m.cStr, ' having ', k_CR + k_TAB + 'having ') cStr= STRTRAN(m.cStr, ' into ', k_CR + k_TAB + 'into ') cStr= STRTRAN(m.cStr, ' group by ', k_CR + k_TAB + 'group by ') cStr= STRTRAN(m.cStr, ' order by ', k_CR + k_TAB + 'order by ') cStr= STRTRAN(m.cStr, ' union ', k_CR + 'union ') cStr= STRTRAN(m.cStr, ' select ', k_CR + 'select ') ok= MessageBox(m.cStr + k_CR + k_CR + 'Continue?', 1+32, 'Developer message')=1 ENDIF IF m.ok IF m.canEsc ON ESCAPE DO RunSQL_Esc WITH m.ok WAIT CLEAR WAIT WINDOW NOWAIT ; IIF(EMPTY(m.cWaitMsg), "Running query", m.cWaitMsg) ; + CHR(13) + "Press 'ESC' to cancel..." SET ESCAPE ON ELSE IF ! EMPTY(m.cWaitMsg) WAIT WINDOW NOWAIT m.cWaitMsg + '...' * do not clear this message in this procedure. Let calling program do that. ENDIF ENDIF SET TALK ON *============ &cSQL *============ SET TALK OFF IF m.canEsc ON ESCAPE WAIT CLEAR && the calling program needs to reset any other required message IF ! og.develop SET ESCAPE OFF ENDIF ENDIF ENDIF RETURN m.ok * =========================== ************************** PROCEDURE RunSQL_Esc ************************** lparameter ok && pass by reference IF ! og.develop SET ESCAPE OFF ENDIF ok= MessageBox('Do you wish to terminate the query?', 36, 'Query abort') = 7 IF m.ok SET ESCAPE ON RETRY *<<<<< ELSE IF og.develop AND MessageBox('Debug?', 36, 'Query abort')=6 SET STEP ON ENDIF ENDIF>I'm would like to know if it is possible to cancel/interrupt an executing SELECT - SQL command. My query could take a long time to finish and I would like to give the user the opportunity to abort the process. There is no WHILE clause to the VFP SELECT - SQL command. Does anyone know how I can do this? Please don't recommend that I try to optimize the query using RUSHMORE. The speed of the query is not my main concern here. The ability to abort the executing SELECT - SQL is.