| Construct to Exit | Syntax | |
|---|---|---|
| Do...Loop | Exit Do | |
| For...Next | Exit For | |
| Function | Exit Function | |
| Sub | Exit Sub | |
| Property | Exit Property | |
| Form | DoCmd.Close | |
| MS Access | Quit DoCmd.Quit CloseCurrentDatabase |
According to the help, Quit (interpreted as Application.Quit) is the preferred command to close MS Access. However, when the wizard creates a Quit Application button, it uses DoCmd.Quit. (VisualBasic uses Unload for this function.)
DoCmd.Close closes the current form. With additional parameters, it can close any open object - Table, Query, Form, Report, Marco, or Module.
CloseCurrentDatabase is used by the Switchboard - it closes the current database without closing MS Access.
| Construct to Exit | Syntax | |
|---|---|---|
| begin...end; | goto xyz; | |
| for...do begin...end; while repeat | Break; Continue; | |
| try..finally | Break; | |
| Function
Procedure | Exit; Abort; | |
| Form | PTConfig_UIForm.Close | |
| Application | Application.Terminate; Exit; Halt; RunError; |
The help suggests using goto to get out of nested loops. When used like this, goto does not violate the basics of structured programming.
Author: Robert Clemenzi - clemenzi@cpcug.org