XL2000: Named Argument Not Found Error with DAO

ID: Q213605


The information in this article applies to:
  • Microsoft Excel 2000


SYMPTOMS

When you run a Microsoft Excel Visual Basic for Applications macro that uses Data Access Objects (DAO), you may receive the following error message:

Compile Error:
Named Argument Not Found


CAUSE

DAO version 3.6, which is included with Excel, does not fully support named arguments. In some cases, named arguments will work without error; however, you should avoid using them.


RESOLUTION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
To work around this behavior, use positional arguments instead of named arguments.

When you call a subroutine or function in a Visual Basic macro, you can supply arguments positionally, in the order in which they appear in the definition of the procedure. Alternatively, you can supply the arguments by name without regard to position. However, with DAO properties and methods, Microsoft recommends that you use only positional arguments.

To use positional arguments, supply the arguments for the method in the correct position, where each argument is delimited by a comma, as shown in the following example:

Set DB = OpenDatabase("C:\My Documents\DB1.MDB", , True) 


MORE INFORMATION

Example of the Problem

The DAO 3.6 OpenDatabase method uses the following syntax:

Set <database> = OpenDatabase(dbname, options, readonly, connect) 
If you use the OpenDatabase method by supplying named arguments in the macro, you may receive the error described in the "Symptoms" section of this article. For example, when you run the following macro, the compile error appears:

Set DB = _
   OpenDatabase(dbname:= "C:\My Documents\DB1.MDB", readonly: = True) 


REFERENCES

For more information about named arguments, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type Understanding Named and Optional Arguments in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Additional query words: parameter OpenRecordset XL2000

Keywords : kberrmsg kbprg kbdta kbdtacode xldao KbVBA xlvbmigrate
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: July 20, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.