PRA: Using DOWN ARROW After Declaring Function Omits End

    Article ID: Q141610
    Creation Date: 20-DEC-1995
    Revision Date: 17-DEC-1996

    The information in this article applies to:

    • Microsoft Access versions 7.0, 97

    SYMPTOMS

    Moderate: Requires basic macro, coding, and interoperability skills.

    After you type the name of a new function or Sub procedure in a module, such as Function myfunc(), Microsoft Access does not automatically generate an End Function or End Sub statement for your new function or Sub procedure. If the module already contains code, that code is visible on the same page following the newly declared statement.

    CAUSE

    You are pressing the DOWN ARROW key to go to a new line after you type the function name instead of pressing the ENTER key.

    RESOLUTION

    You can use either of the following methods to work around this problem.

    Method 1

    View the module in full Module view. To do so:

    1. On the Tools menu, click Options.
    2. Click the Modules tab.
    3. If it is not already selected, click to select the Full Module View check box.

    Method 2

    Always use the ENTER key to go to a new line when declaring a function or Sub procedure. If you have started a function or Sub procedure and pressed the DOWN ARROW key, you must type the End Function or End Sub statement at the end of your code.

    STATUS

    Microsoft has confirmed this to be a problem in Microsoft Access 7.0 and

    1. We are researching this problem and will post new information here in
    the Microsoft Knowledge Base as it becomes available.

    MORE INFORMATION

    Steps to Reproduce Problem

    1. Open the sample database Northwind.mdb.
    2. On the Tools menu, click Options.
    3. Click the Modules tab.
    4. If it is selected, click to clear the Full Module View check box.
    5. Click OK to close the Options dialog box.
    6. In the Database window, click the Modules tab, and then click Design to open the Utility Functions module.
    7. Under the Option Explicit line, type the following function name:

            Function MyFunc()
      
    8. Press the DOWN ARROW key instead of the ENTER key. Note that the Module now looks as follows:

            Function MyFunc()
      

            Function IsLoaded(ByVal strFormName As String) As Integer
            'Returns True if the specified form is open in Form view or Datasheet
            'view.
      

               Const conObjStateClosed = 0
               Const conDesignView = 0
      

                  If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> _
                       conObjStateClosed Then
                  If Forms(strFormName).CurrentView <> conDesignView Then
                       IsLoaded = True
                  End If
               End If
      

            End Function
      

    Microsoft Access did not generate an END Function statement for the MyFunc() function, and the IsLoaded() function is visible in the module.


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.
©1997 Microsoft Corporation. All rights reserved. Legal Notices.

KBCategory: kbprg
KBSubcategory: MdlDecl
Additional reference words: 7.00 97 8.00 Subroutine