Visit our new web pages

We have launched a new extended set of web pages at www.alvechurchdata.co.uk. These old pages will stay on the server because people still have links to them but they will not be updated.

The new version of this page is at www.alvechurchdata.co.uk/hints-and-tips/foxcannotquit.html.

Cannot quit Visual FoxPro


The 'Cannot Quit Visual FoxPro' message must be one of the most common problems you meet when starting to work with Visual FoxPro.

It has been with us since the launch of Visual FoxPro but the problem still causes difficulties. The error message does not give an error number so you cannot find it in the Help system. Help returns nothing if you search for 'Cannot Quit Visual FoxPro' and MSDN is equally unhelpful. A search on Google though will show you that it's a very common question in all the support forums so it's disappointing that Microsoft have not added it to Help.

Especially as it is a very simple problem to fix.

Close the application

The first thing to do is to close the application that has locked. The least damaging way of doing this is to use the Windows Task Manager. In Windows 2000 and Windows XP you can open the Task Manager by pressing Ctrl+Alt+Del or by right-clicking on the Windows status bar. Select Task Manager from the options that appear then click the Applications on the Task Manager dialog:

[Windows Task Manager]

Select your Visual FoxPro application from the list then click the End task button. You will be warned that this is an extreme act and asked to confirm that you do indeed want to cancel this process. Click OK and wait. Windows may take several seconds to complete the task of closing down the application. When it has been closed you will be told that you have terminated FoxPro prematurely and asked whether you want to report the problem to Microsoft. We have been reporting this for ten years now so I suspect it will be a waste of time to report it again.

Now that you have cancelled the application, close the Task Manager and open your project in FoxPro.

Solution

The problem arises because Visual FoxPro is event-driven. The RunTime engine opens your executable and then responds to events as they occur. You have closed your application but not told FoxPro to stop waiting for events.

The command to stop the event-processing loop is:

Clear Events

and FoxPro must execute this command whichever way that the application closes down. Depending on the structure of your application you might put the command is several places:

  • In the procedure called by the Quit option on the File menu.
  • In the Click event of the button that closes your main form.
  • When the application shuts down:
    On Shutdown Clear Events

FoxPro executable flashes on screen and vanishes

The other problem you'll hit with the FoxPro event-processing loop is when you find that your executable won't run outside of the development environment. You just see a flash of your main form on screen before the executable closes. More details here .


Hints & tips

The textbox class in Visual FoxPro 9 has a new Autocomplete property which shows the user the previous values that have been entered in that textbox.
Autocomplete in VFP 9

Your Access database will look more impressive if you add custom toolbars...
Custom toolbars

FoxPro has always had functions to read and write files at a low level...
Foxpro low level file functions

More...
More pages of hints and tips for users of Microsoft FoxPro and Access databases.

Site Map