Microsoft KB Archive/126984

= MSQUERY: FieldDef Request Item Returns Dimensional Array =

Article ID: 126984

Article Last Modified on 11/23/2006

-

APPLIES TO


 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Excel 98 for Macintosh
 * Microsoft Excel 5.0 for Macintosh
 * Microsoft Query 2000

-



This article was previously published under Q126984



SYMPTOMS
When you use DDE with Microsoft Query, the FieldDef request item should return a two-dimensional array, where each row of the array describes a field in the query. The expected array should be n rows by 5 columns (where n is the number of fields in the result set). However, if the result set contains only one field, a DDE request for the FieldDef item will return a one-dimensional array that has dimensions of 5 rows by 1 column rather than a two-dimensional array that has dimensions of 1 row by 5 columns.

Note that if the result set contains more than one field, FieldDef will correctly return a two-dimensional array.



STATUS
Microsoft has confirmed this to be a problem with Microsoft Query. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
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 Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

https://partner.microsoft.com/global/30000104

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

Sample Visual Basic Procedure
The following is an example of a Microsoft Visual Basic for Applications macro that uses DDE with Microsoft Query and displays all of the field names in the result set created in Microsoft Query. Sub GetQueryFields Dim Chan, Fields, NumCols as Variant Dim I as Integer

'Launch Microsoft Query Shell "C:\WINDOWS\MSAPPS\MSQUERY\MSQUERY.EXE",1

'Initialize a channel to Query Chan = DDEInitiate ("MSQuery","System")

'Give control to Query and allow the user to build a result set. DDEExecute Chan, "[UserControl('&Return',3,true)]"

'Issue a request for the field definitions on the channel Fields=DDERequest(Chan, "FieldDef")

'Issue a request for the number of columns in the result set NumCols = DDERequest(Chan, "NumCols")

'Quit Query and Close the channel to Query DDEExecute Chan, "[Exit(True)]" DDETerminate Chan

'Display the names of all the fields in the result set If NumCols(1) = 1 then Msgbox Fields(1) Else For I= 1 to NumCols(1) Msgbox Fields(i,1) Next I  End If

End Sub NOTE: To use this macro example with Excel 5.0 for the Macintosh, replace the macro line DDEExecute Chan, "[UserControl('&Return',3,true)]" with: DDEExecute Chan, "[UserControl(""&Return"",""3"",""true"")]"

