MSQuery: DDE Command Fetch.Unadvise Does Not Break Link
ID: Q149875
|
The information in this article applies to:
-
Microsoft Query for Windows, version 1.0
-
Microsoft Query for Windows 95, version 2.0
SYMPTOMS
When you use the Microsoft Query Fetch.Unadvise DDE command to break a link
that was created with Fetch.Advise, the link may not be broken.
WORKAROUND
To work around this problem, close each query window when you are finished
working with it and then create a new one with the Microsoft Query DDE
command OPEN. The following macro is an example of using this method.
Microsoft 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 professionals 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.
To run the macro, do the following:
- Start Microsoft Query.
- Create a data source with the name of Nwind, using the dBASE files included with Microsoft Excel.
- In the workbook that contains the macro code, make sure there is a
worksheet named Sheet1.
- Type the following procedure into a module sheet:
Sub Using_FetchAdvise()
Dim NumRows
Dim NumCols
'create a channel to Query
chan = DDEInitiate("MSQuery", "System")
'log onto the NWind data source
DDEExecute chan, "[Logon('nwind')]"
'issue a select statement
DDEExecute chan, "[Open('Select * From Customer')]"
'request the number of rows and columns in the result set
NumRows = DDERequest(chan, "NumRows")
NumCols = DDERequest(chan, "NumCols")
'return the data to the Excel sheet with a hot link
DDEExecute chan, "[Fetch.Advise('Excel','Sheet1','R1C1:R" & NumRows(1) _
& "C" & NumCols(1) & "','All/Headers')]"
'stops the macro
'at this point you can go into Query and change the data so that it will
'update the data on sheet1
'Press F5 to continue the macro
Stop
'close the query window
DDEExecute chan, "[Close()]"
'issue a select statement
DDEExecute chan, "[Open('select * from customer')]"
'request the number of rows and columns in the result set
NumRows = DDERequest(chan, "NumRows")
NumCols = DDERequest(chan, "NumCols")
'return the data to the Microsoft Excel sheet with a hot link
DDEExecute chan, "[Fetch.Advise('Excel','Sheet1','R1C1:R" & NumRows(1) _
& "C" & NumCols(1) & "','All/Headers')]"
'close the query window
DDEExecute chan, "[Close()]"
'logoff of NWind
DDEExecute chan, "[Logoff('NWind')]"
'terminate the DDE channel
DDETerminate chan
End Sub
- Run the macro.
STATUS
Microsoft 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.
REFERENCES
"Microsoft Query User's Guide," version 1.0, Chapter 9, "Using Dynamic Data
Exchange with Microsoft Query"
For more information about Fetch.UnAdvise, click the Search button in
Microsoft Query Help and type:
Fetch
Additional query words:
dynamic programmatically programming
Keywords : xlquery
Version : WINDOWS:1.0,2.0
Platform : WINDOWS
Issue type :
|