Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: DDEREQUEST May Truncate the Results of a Query


View products that this article applies to.

This article was previously published under Q213794

↑ Back to the top


Symptoms

If you use DDERequest to retrieve the SQL statement (QueryDefinition function) or the Open Database Connectivity (ODBC) SQL Statement (ODBCSQLStatement function) from Microsoft Query, the results may be truncated.

Sample statements that can produce this condition are as follows
  • DDERequest(channel, "QueryDefinition")
  • DDERequest(channel, "ODBCSQLStatement")
where channel is the dynamic data exchange (DDE) to Microsoft Query channel variable.

↑ Back to the top


Workaround

You can avoid the truncation by using the following array forms of these functions
  • DDERequest(channel, "QueryDefinition/n")

    -and-
  • DDERequest(channel, "ODBCSQLStatement/n")
where channel is the DDE to Microsoft Query channel variable.

The array form of these functions parses the SQL statement into array elements. You can use the following Visual Basic for Applications code sample to place the SQL statement on a worksheet using the array form of these functions.

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: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
Before you run this subroutine, be sure that Microsoft Query 2000 is open and that you understand how to select a data source and return data to Microsoft Excel.

For more information about using Microsoft Query, click Microsoft Excel Help on the Help menu, type microsoft query in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

Sample Visual Basic Code

Type the following code in a module sheet:
Sub TestArrayQueryDefinition()
   '   Activate a worksheet.
   Worksheets(1).Activate
   '   Initiate a Channel to MSQuery.
   Chan = DDEInitiate("MSQUERY", "System")
   '   Give the user control in Microsoft Query so they can select data
   '   from a database and return to Excel.
   DDEExecute Chan, "[UserControl('&Return to Excel',3,true)]"
   '   At this point the code opens Microsoft Query and waits
   '   for the user to select a Data Source, Data Table(s), and data to
   '   return to Microsoft Excel.
   '   To request the Query Definition be parsed into of 50 character
   '   sections...
   QryDefArray = DDERequest(Chan, "QueryDefinition/50")
   '   To format the parsed Query Definition data...
   ArrayLen = UBound(QryDefArray, 1)
   Range("A1").Value = "Query Definition (renamed Column Names) in " _
   & ArrayLen & " parts:"
   '   If the Array length is one then a one dimension array is returned,
   '   if the Array length is greater than one, a two dimension array is
   '   returned.
   If ArrayLen = 1 Then
   '   Place the single line of data on the worksheet and remove wrap text.
      Range("A2") = QryDefArray(1): Range("A2").WrapText = False
   Else
   '   Place the parsed lines of data on the worksheet and remove wrap
   '   text.
      For i = 1 To ArrayLen
         Range("A" & i) = QryDefArray(i, 1)
         Range("A" & i).WrapText = False 'To undo wrap text
      Next i
   End If
End Sub
				

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


Keywords: KB213794, kbprogramming, kbpending, kbbug

↑ Back to the top

Article Info
Article ID : 213794
Revision : 7
Created on : 11/23/2006
Published on : 11/23/2006
Exists online : False
Views : 391