Microsoft KB Archive/151278

= DDEREQUEST May Truncate Results =

Article ID: 151278

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition
 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Query 2000

-



This article was previously published under Q151278



SYMPTOMS
If you use DDERequest to retrieve the Structured Query Language (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(, "QueryDefinition/n") DDERequest(, "ODBCSQLStatement/n") where is the dynamic data exchange (DDE) to Microsoft Query channel variable.



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements. You can avoid the truncation by using the following array form of these functions: DDERequest(, "QueryDefinition/n") DDERequest(, "ODBCSQLStatement/n") where 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.

Sample Visual Basic Code
Before you run this subroutine, be sure that Microsoft Query 2.0 is open and you understand how to select a data source and return data to Microsoft Excel. If you have any questions regarding this topic, please see "Getting Started with Microsoft Office for Windows 95" and Microsoft Query Help.

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



STATUS
Additional query words: XL5 XL7 XL97 5.00c 8.00 97 XL

Keywords: kbprogramming KB151278

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.