MSQUERY: DDE Commands Available Only on System ChannelLast reviewed: September 2, 1997Article ID: Q125492 |
1.00 2.00
WINDOWS
kbtool kbprg
The information in this article applies to:
SYMPTOMSWhen you use an application that supports dynamic data exchange (DDE) to initiate a DDE conversation with Microsoft Query, a DDE command that you use may fail to complete, may return an error message, or may return unexpected results.
CAUSEThis behavior occurs if you initiate a DDE conversation using a query channel and if you use a DDE command that is only supported on a system channel. You can use a system channel to establish a DDE conversation with Microsoft Query to return general and query-related information. You use a query channel to establish a DDE conversation with a specific query in Microsoft Query. The following is a list of the DDE commands that you can use with Microsoft Query. The commands marked with an asterisk (*) are commands that are only supported on a system channel and that cannot be used on a query channel:
Activate* AllowEdit BuildSQL* Close Command* Exit* Fetch and Fetch.Advise Fetch.Unadvise Logoff* Logon* ODBCLogon* Open* QueryNow SaveAs SetWindowState UserControl* ViewPane WORKAROUNDTo avoid returning an error when you use one of the Microsoft Query DDE commands that is only supported on a system channel, use a system channel instead of a query channel in the DDE conversation. The following Visual Basic, Applications Edition, examples show how to establish a DDE conversation with Microsoft Query using either a system channel or a query channel.
System Channel
Sub UsingSystemChan()Dim chan As Integer Dim sql As String
' Establish DDE conversation using system channel chan = DDEInitiate("MSQUERY", "System") ' logon using NWind data source DDEExecute chan, "[Logon('NWind')]" ' Execute an SQL query to retrieve all records from Customer table DDEExecute chan, "[Open('SELECT Custmr_ID FROM Customer')]" 'Return data to Sheet1 at cells A1:A63 DDEExecute chan, "[Fetch('Excel', 'Sheet1', 'R1C1:R63C1', 'All')]" ' Close the DDE channel DDETerminate chan End Sub Query Channel
Sub UseQueryChannel()Dim chan As Integer Dim NRows, NCols
' Establish DDE conversation using query channel ' ** Note that QUERY1 must be open in Microsoft Query ' in order for the following command to work chan = DDEInitiate("MSQUERY", "query1") 'Determine the number of rows and columns in query1 NRows = DDERequest(chan, "NumRows") NCols = DDERequest(chan, "NumCols") ' Return the data in Query1 to Sheet1 starting at A1. ' ** The following two lines should be entered on one line. DDEExecute chan,"[Fetch('Excel', 'Sheet1', 'R1C1:R" & NRows(1) & "C" & NCols(1) & "', 'All')]" ' Close the DDE channel DDETerminate chan End SubMicrosoft provides examples of Visual Basic for Applications procedures 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. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.
STATUSMicrosoft has confirmed this to be a problem in the Microsoft Products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
REFERENCESFor more information about individual DDE commands, such as the Activate command, choose the Search button in Help and type:
DDE commands |
Additional reference words: 1.00 2.00 5.00 5.00a 5.00c 7.00 7.00a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |