MSQUERY: FieldDef Request Item Returns Dimensional Array (126984)
The information in this article applies to:
- Microsoft Excel for Windows 95
- Microsoft Excel for Windows 5.0
- Microsoft Excel 98 Macintosh Edition
- Microsoft Excel for the Macintosh 5.0
- Microsoft Query
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 INFORMATIONMicrosoft 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:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
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:
163435 VBA: Programming Resources for Visual Basic for Applications
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbbug kbcode kbinterop kbProgramming KB126984 |
---|
|