ACC97: Errors in "GetObject Function" Example in Help

ID: Q167590


The information in this article applies to:

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


SYMPTOMS

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") 

Additional query words:


Keywords          : kberrmsg kbole IntpOlea 
Version           : WINDOWS:97
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: August 5, 1999