XL: SQLRetrieve Defines Field Names on Active WorkbookLast reviewed: December 1, 1997Article ID: Q117644 |
The information in this article applies to:
SUMMARYIn Microsoft Excel, if you are using the Visual Basic, Applications Edition SQLRetrieve command, and you want each column of results to be declared as a named range on the worksheet, you can set the "NamedRngLogical" argument to TRUE. The name of each range is the field name of a column's result set. The syntax for the SQLRetrieve statement is as follows:
SQLRetrieve(ConnectionNum, DestinationRef, MaxColumns, MaxRows, ColNamesLogical, RowNumsLogical, NamedRngLogical, FetchFirstLogical)When you execute the SQLRetrieve command with the argument "NamedRngLogical" set to TRUE, the column names in the result set will always be defined on the active workbook regardless of what the "DestinationRef" argument is set to. If no workbooks are active when you run the SQLRetrieve command, and if "NamedRngLogical" is set to TRUE, you will receive the #N/A error value; however, the records will still be retrieved to the range specified by destination. NOTE: The information in this article also applies to the Microsoft Excel 4.0 command SQL.EXEC.QUERY.
MORE INFORMATION
Visual Basic Code ExampleMicrosoft 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 engineers 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 the Microsoft fee-based consulting line at (800) 936-5200. 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/refguide/default.aspNote that a line that is preceded by an apostrophe introduces a comment in the code--comments are provided to explain what the code is doing at a particular point in the procedure. Note also that an underscore character (_) indicates that code continues from one line to the next. You can type lines that contain this character as one logical line or you can divide the lines of code and include the line continuation character. For more information about Visual Basic for Applications programming style, see the "Programming Style in This Manual" section in the "Document Conventions" section of the "Visual Basic User's Guide." The following sample Visual Basic code uses the CUSTOMER.DBF file included with the sample data source NWind and assumes that:
|
Additional query words: 5.00 5.00a 5.00c 7.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |