ACC: How to Communicate with NetDDELast reviewed: June 6, 1997Article ID: Q99939 |
The information in this article applies to:
SUMMARYAdvanced: Requires expert coding, interoperability, and multiuser skills. This article demonstrates how to use NetDDE to communicate with Microsoft Access on a remote computer. This article assumes that you are familiar with DDE communications on a local computer, and with the capabilities of Microsoft Access as a DDE server. 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.
MORE INFORMATIONIn order to establish a link to a remote application, a DDE share must be created on the remote computer. A DDE share is a name that represents an application name, a topic, and any permissions for that topic. A DDE conversation can only occur with applications and topics assigned to share names on the remote computer. Note that a utility called Network DDE Share Manager (provided with the Windows for Workgroups Resource Kit) can be used to create and edit DDE share names.
How to Create the DDE ShareThe following steps demonstrate how to create a DDE share for the Employees table in the sample database NWIND.MDB:
How to Communicate with the Remote Microsoft Access DDE ShareNOTE: Before running the following function, make sure that Microsoft Access is running on the remote computer and that the NWIND.MDB database is open. Create the following procedure in a Microsoft Access module on your local computer: NOTE: In the following sample code, an underscore (_) is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in Access Basic.
Option Explicit Function GetRemoteEmployeeInfo() Dim iChan As Integer Dim EmpRecord As String, FieldNames As String iChan = DDEInitiate("\\RemoteMachineName\NDDE$", _ "Northwind Employees") FieldNames = DDERequest(iChan, "FieldNames") MsgBox FieldNames, 0, "Employee Table Field Names" On Error Resume Next EmpRecord = DDERequest(iChan, "FirstRow") Do Until EmpRecord = "" MsgBox EmpRecord, 0, "Employee Record" EmpRecord = "" EmpRecord = DDERequest(iChan, "NextRow") Loop End FunctionChange the first argument of the DDEInitiate command (RemoteMachineName) to reference the name of your remote computer. When you run this function from the Immediate window, a message box will be displayed that shows a list of field names in the Employees table. Next, a series of message boxes will appear displaying each record from the table. The field data will be delimited by a tab character.
The DDEInitiate StatementNote the arguments used in the DDEInitiate command to establish the link with the remote share. The application name is the net DDE server application NDDE$ located on the remote computer "\\RemoteMachineName". NDDE$ is a system service application that is run automatically by Windows for Workgroups in the background. This application is always running and present when Windows for Workgroups is running and cannot be terminated. When NDDE$ receives the topic "Northwind Employees" it checks the list of available DDE shares on the local computer. If it finds the share, it will validate any permissions on the share and prompt for a password if one is required. After the validation is complete, NDDE$ establishes a local DDE link with the application name and topic assigned to the share name. Once the link has been established, communication with the client application proceeds as if it were another application on the local computer. NDDE$ becomes the liaison between the two applications across the network.
REFERENCESFor more information on Microsoft Access as a DDE server, search on "DDE server," using the Microsoft Access Help Index. Microsoft Windows for Workgroups "Resource Kit," Chapter 11
|
Additional query words: dynamic data exchange
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |