DOCUMENT:Q94695 04-MAY-2001 [vbwin] TITLE :Error: Executable code not allowed in module level of a form PRODUCT :Microsoft Visual Basic for Windows PROD/VER:MS-DOS:1.0 OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic for MS-DOS 1.0 ------------------------------------------------------------------------------- SUMMARY ======= You can't use the On Error Goto and On Event Gosub statements in a form because they require an event handler at the module level, and you can't enter code at the module level of a form. Attempting to enter code at the module level of a form results in an error: Executable code not allowed in module level of a form Line labels and line numbers are allowed in the module level of a form module, but they are useless. To work around this limitation, use On Error and On Event statements only in code (.BAS) modules or use the On Local Error statement for error trapping. MORE INFORMATION ================ This limitation applies to the following statements: On Error On Com On Key On Pen On Play On Strig On Timer On UEvent Additional query words: VBmsdos 1.00 ====================================================================== Keywords : Technology : kbVBSearch kbAudDeveloper kbZNotKeyword3 kbVB100DOS Version : MS-DOS:1.0 ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2001.