ACC97: Errors in "GetObject Function" Example in Help

Last reviewed: August 29, 1997
Article ID: Q167590
The information in this article applies to:
  • Microsoft Access 97

SYMPTOMS

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

If you copy the example from the "GetObject Function" Help topic in Microsoft Access 97 and paste it into a module, you may receive the following error message when you compile your code:

   Compile error:

   Expected: list separator or )

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.

CAUSE

This error is caused by missing commas in the Declare statement for the SendMessage function. A comma is missing after the ByVal wMsg As Long argument and after the ByVal wParam As Long argument for this function.

NOTE: If you insert the missing commas and try to compile your code, you receive another error:

   Compile error:

   Syntax error

This error is caused by a missing apostrophe (') before the following comment:

   Set the object variable to reference the file you want to see.

RESOLUTION

Modify the following portions of the code in the Help example to include the two missing commas and the missing apostrophe.

Add the Two Missing Commas

Add a comma in the SendMessage Function after the ByVal wMsg As Long argument and after the ByVal wParam As Long argument as follows:

   Declare Function SendMessage Lib "user32" Alias _
   "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
                   ByVal wParam As Long, _
                   ByVal lParam As Long) As Long

Add an Apostrophe for the Comment

Add an apostrophe (') to remark the "Set the object variable to reference the file you want to see" comment as follows:

   ' Set the object variable to reference the file you want to see.
      Set MyXL = GetObject("c:\vb4\MYTEST.XLS")
Keywords          : AutoGnrl DcmHlp kberrmsg kbole PgmApi SynGnrl IntpOleA
Version           : 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbprb
Solution Type     : Info_Provided


================================================================================


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.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.