.START:
.AUTHOR: Kimberh
.PRODUCT: B_WACCESS
.TITLE: Parameter Queries Are Not Supported As DDE Topics 
.VERSION(S): 1.00 
.OPERATING SYSTEM(S): WINDOWS 
.SECURITY: ENDUSER
.REFERENCE: ENDUSER 
.ARTICLE TEXT:
------------------------------------------------
The information in this article applies to:

 - Microsoft Access, version 1.00
------------------------------------------------------------

Summary:
MS Access does not support Parameter Queries via DDE. 
Parameter driven queries require parameters for which MS 
Access has no mechanism to 
receive via DDE. 

More Information:
Attempts to initiate a DDE channel with a parameter query 
will fail.  The resulting error message is dependent upon
the DDE Client. In Microsoft Visual Basic the user will 
see: "No foreign application responded to DDE Initiate".
In Microsoft Excel the error message is: 
   "Remote Data not Accessible. Start 'MSACCESS.EXE'?"

One work around is to link an MS Access form to the DDE 
client. This link will transfer the parameter to MS Access. 
Then the modify the query to refer to the form for the 
parameter.  The steps to use this method with Microsoft 
Excel follow: 


A. Create the DDE Link
-------------------
1) Start Microsoft Excel and open a new Macro sheet.
2) In cell A1 enter "DAIR" without quotation marks.
3) Save the macro sheet as DDETEST.XLM.
4) Select cell A1 and choose Copy from the Edit menu.
5) Start MS Access and open the Northwind Traders 
   database, NWIND.MDB.
6) Create a new, unbound form.
7) Choose Paste Special from the Edit menu.
8) Select Text in the Data Type list box and then click 
   Paste Link. This creates a Text box with the formula: 
       =DDE("Excel","C:\ACCESS\DDETEST.XLM","R1C1")
9) If the Properties box is not available choose Properties 
   from the View menu. 
10) Select the text box created in step 7 and change the 
    Control Name property to: DDE Parameter.
11) Save the form as [DDE Link Form].


B. Modify the Query
----------------
1) Open the query [Products By Category (Parameter)] in
    design mode.
2) Select Parameters from the Query menu and delete the entry 
    [Enter a Category ID].
3) Under the field [Category ID] in the query grid replace the 
     existing criteria with: 
         =Forms![DDE Link Form]![DDE Parameter]
4) To test the query verify that the macro sheet DDETEST.XLM
   is open in Microsoft Excel and that the form 
   [DDE Link Form] is in Browse mode. Run the query and 
   verify that the products are in the category "DAIR".


C. Create a Macro to Open the Form
----------------------------------
1) Create a new macro.
2) Add the following macro action:

   OpenForm     Form Name:  DDE Link Form
                View:  Form

3) Save this macro as "Open Form", without quotes.


D. Create a Macro to Run the Query
----------------------------------
1) Create a new macro.
2) Add the following macro action:

   OpenQuery    Query Name:  Products by Categories (Parameter)
                View:  Datasheet

3) Save this macro group as "Run Query", without quotes.


E. Create the DDE Macro
--------------------
1) In the macro sheet DDETEST.XLM enter the following macro:

   A1 DAIR
   A2   
   A3 chan=INITIATE("MSAccess","System")
   A4 =EXECUTE(chan,"Open Form")
   A5 =APP.ACTIVATE("Microsoft Access")
   A6 =SEND.KEYS("{F9}")
   A7 =TERMINATE(chan)
   A8 =ON.TIME(0.010,Run_Query)
   A9
   A10 chan=INITIATE("MSAccess","System")
   A11 =EXECUTE(chan,"Run Query")
   A12 =TERMINATE(chan)
   A13 =RETURN()


2) Place your cursor in cell A10, choose Define Name from 
   the Formula menu, enter Run_Query in the Name: box. Click
   the option Command and then choose OK. This gives the 
   name Run_Query to the second  macro.

3) Close all forms, macros, and queries in Access.

4) To run the macro place your cursor in cell A3, choose 
    Run from the Macro menu, and then press OK.
   The Excel macro will run much more quickly is you set the
   DDE TimeOut option in Access to 1 second.

Notes: 
   Why are SendKeys used? 
      Excel has instructed Microsoft Access to open the 
      form[DDE Link Form]. When Microsoft Access opens 
      the form it will attempt to update the DDE link in
      the control [DDE Parameter]. However, Excel will 
      not process any requests until it receives 
      notification that Access has successfully completed
      the macro. MS Access will not finish executing until
      it successfully updates the link to Excel. Eventually
      MS Access will time-out and display #Error. The
      SendKeys command sends the key sequence F9 which 
      refreshes the form. 

   How would you get this information to Excel?
      If you need to transfer the result of the query to
      Excel change the query to a Make Table query. You 
      will then be able to use the DDE Request function 
      to retrieve the data in the table from Excel.

Reference:
The DDE Server Topics supported by Microsoft Access are
      documented in the file README.TXT which in 
      installed in your Access directory.

For information on parameter queries refer to the Microsoft 
      Access User's Guide, Chapter 7 Designing Action 
      Queries and Parameter Queries, pp.178-181

For information on creating DDE links in forms and reports 
      refer to the Microsoft Access User's Guide, Chapter 
      13 Using Picture, Graphs, and Other Objects, pp.337-339

Additional reference words: 1.00 
.END:
