MSQUERY: FieldDef Request Item Returns Dimensional Array

Last reviewed: February 3, 1998
Article ID: Q126984
The information in this article applies to:
  • Microsoft Query for Windows, version 1.0
  • Microsoft Query version 2.0 for Windows 95
  • Microsoft Query 97 for Windows
  • Microsoft Query for Macintosh, version 1.0
  • Microsoft Query 98 Macintosh Edition

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 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.asp

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

REFERENCES

"Microsoft Query User's Guide," Chapter 9

For additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q163435
   TITLE     : VBA: Programming Resources for Visual Basic for
               Applications


Additional query words: 1.00 MSQuery querry w_exceL m_excel
Keywords : kbcode kbinterop kbprg IntpDde PgmHowto
Version : WINDOWS:1.0,2.0,97; MACINTOSH:1.0,98
Platform : MACINTOSH WINDOWS
Issue type : kbbug
Solution Type : kbworkaround


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: February 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.