ACC1x: How to Use DDE to Pass Information to MS Access 1.x |
Q100167
You cannot poke data into a table through a dynamic data exchange (DDE)
channel in Microsoft Access. However, you can use a function with
parameters in a DDE channel to the SQL topic to pass information to an
Access Basic function. The data can then be processed by the function and
added to a table.
This article assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools
provided with Microsoft Access. For more information on Access Basic,
please refer to the "Introduction to Programming" manual in Microsoft
Access version 1.x, or the "Building Applications" manual, Chapter 3,
"Introducing Access Basic" in version 2.0.
The following example explains how to add a new customer to the Customers
table in the sample database NWIND.MDB, using data from Microsoft Excel:
Function AddNewCust$ (CustomerID$, CompanyName$)
Dim MyDB As Database, MyTable As Table
Set MyDB = CurrentDB()
Set MyTable = MyDB.OpenTable("Customers") ' Open table.
MyTable.AddNew ' Prepare new record.
MyTable("Customer ID") = CustomerID$ ' Set record key.
MyTable("Company Name") = CompanyName$ ' Set company name.
MyTable.Update ' Save changes.
MyTable.Close ' Close table.
End Function
AddNewCustomer
chan=INITIATE("MSACCESS","NWIND.MDB;SQL SELECT_
AddNewCust$(""JOHNJ"",""John's Place"") FROM None; ")
=TERMINATE(chan)
=RETURN()
Sub MAIN
qt$ = Chr$(34)
Funct$ = "AddNewCust$(" + qt$ + "JOHNJ" + qt$ + "," + qt$ + _
"John's Place" + qt$ + ")"
Chan = DDEInitiate("MSACCESS", "NWIND;SQL SELECT " + Funct$ + _
" FROM None;")
DDETerminate Chan
End Sub Microsoft Access "Language Reference," version 1.0, pages 118-124
Additional query words: dde excel macro ddepoke
Keywords : kbinterop
Issue type : kbhowto
Technology : kbAccessSearch kbAccess110 kbAccess100
|
Last Reviewed: November 6, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |