ACC: Topics Supported by Microsoft Access as a DDE ServerID: Q89586
|
Advanced: Requires expert coding, interoperability, and multiuser skills.
Microsoft Access supports dynamic data exchange (DDE) as both a client
(destination) and a server (source) application. This article lists the
DDE topics that Microsoft Access supports as a DDE server and the valid
DDE items for each topic.
NOTE: All the examples in this article require that you have the sample
database Northwind.mdb in Microsoft Access version 7.0 (or NWIND.MDB in
earlier versions) open.
NOTE: For information about using Microsoft Access as a DDE server in
Microsoft Access 97, search the Help Index for "DDE, overview."
As a DDE server, Microsoft Access supports the following topics:
Chan = DDEInitiate("MSAccess", "System")
Topics$ = DDERequest$(Chan, "Topics")
DDETerminate Chan
MsgBox Topics$, "Topics", 64
In version 7.0:
Chan = DDEInitiate("MSAccess", "Northwind")
TableList$ = DDERequest$(Chan, "TableList")
MsgBox TableList$, "TableList", 64
DDETerminate Chan
In earlier versions:
Chan = DDEInitiate("MSAccess", "Nwind")
TableList$ = DDERequest$(Chan, "TableList")
MsgBox TableList$, "TableList", 64
DDETerminate Chan
<DatabaseName>; TABLE <TableName>
<DatabaseName>; QUERY <QueryName>
<DatabaseName>; SQL <SQLString>
<DatabaseName> The name of the database to which the table or query
belongs or the SQL statement applies, followed by
a semicolon (;). The database name can be either the
base name only (for example, Northwind or Nwind), or
its full path and .mdb extension (for example,
C:\Msoffice\Access\Samples\Northwind.mdb or
C:\Access\Nwind.mdb).
<TableName> The name of an existing table.
<QueryName> The name of an existing query.
<SQLString> A valid SQL SELECT statement of up to 256 characters,
ending with a semicolon (;). Note that you can
exchange more than 256 characters by omitting the
<SQLString> statement and using successive DDEPoke()
statements to build an SQL statement. For example, the
following WordBasic code uses the DDEPoke() function
to build an SQL statement and request the results of
the query:
Chan1 = DDEInitiate("MSAccess", "Northwind;SQL")
DDEPoke Chan1, "SQLText", "SELECT *"
DDEPoke Chan1, "SQLText", " FROM Orders"
DDEPoke Chan1, "SQLText", " WHERE [Freight] > 100;"
Res$ = DDERequest$(Chan1, "NextRow")
MsgBox Res$, "NextRow", 64
DDETerminate Chan1
All All data in the table, including field names.
Data All rows of data, without field names.
*FieldNames A single-row list of field names.
FieldNames;T Two data records, the first a list of field names,
and the second a list of data types. The data types
are:
0 Invalid
1 True/False (non-NULL)
2 Unsigned byte (Byte)
3 2-byte signed integer (Integer)
4 4-byte signed integer (Long)
5 8-byte signed integer (Currency)
6 4-byte single-precision floating point (Single)
7 8-byte double-precision floating point (Double)
8 Date/Time (date is integer, time is fraction)
9 Binary data, 255-byte maximum
10 ANSI text, not case sensitive, 255-byte
maximum (Text)
11 Long binary (OLE Object)
12 Long text (Memo)
NextRow The data in the next row in the table or query.
When you first open a channel, NextRow returns the
data in the first row. If the current row is the last
record and you execute NextRow, the request fails.
PrevRow The data in the previous row in the table or query.
If PrevRow is the first request on a new channel, the
data in the last row of the table or query is
returned. If the first record is the current row, the
request fails.
FirstRow The data in the first row of the table or query.
LastRow The data in the last row of the table or query.
FieldCount The number of fields in the table or query.
*SQLText An SQL statement representing the table or query.
For tables, this item returns an SQL statement in the
"SELECT * FROM table;" format.
*SQLText;<n> An SQL statement in <n>-character chunks that
represents the table or query, where <n> is an
integer lower than 255. For example, for a query
represented by the SQL statement "SELECT * FROM
Orders;" the item "SQLText;7" would return the
following tab-delimited chunks:
SELECT
* FROM
Orders;
Sub MAIN
Chan1 = DDEInitiate("MSAccess", "Northwind;TABLE Products")
'Get a count of the number of Product records where the
'Product ID is less than 10.
SQL$ = "SELECT Count([Product ID]) AS [CountOfProducts] "
SQL$ = SQL$ + "FROM Products WHERE [Product ID] < 10;"
Chan2 = DDEInitiate("MSAccess", "Northwind;SQL " + SQL$)
ProductCount = Val(DDERequest$(Chan2, "FirstRow"))
DDETerminate Chan2
' Quit if there are no records.
If ProductCount <> 0 Then
Msg$ = "Northwind Product Information:"
Msg$ = Msg$ + " Record Count:" + Str$(ProductCount)
MsgBox Msg$
' Request the first row of data from the Products table.
Data$ = DDERequest$(Chan1, "FirstRow")
' Display the records.
For i = 1 To ProductCount
MsgBox Data$
' Get the next row of data, if not at the end.
If i <> ProductCount Then
Data$ = DDERequest$(Chan1, "NextRow")
End If
Next i
End If
End Sub
Chan = DDEInitiate("MSACCESS", "System")
AppActivate "Microsoft Access"
DDEExecute Chan, "[OpenForm Categories,,,,,2]"
DDEExecute Chan, "[OpenForm Categories]"
DDETerminate Chan
<DatabaseName> A string expression that is the name of an existing
database. This can include the fully qualified
MS-DOS path.
[Exclusive] A Boolean value that is True (-1) if the database is
to be opened with exclusive (nonshared) access and
False (0) if the database is to be opened with shared
access. The default is shared access.
[ReadOnly] A Boolean value that is True if the database is to be
opened with read-only access and False if it is to be
opened with read/write access. The default is
read/write access.
Chan = DDEInitiate("MSACCESS", "System")
DDEExecute Chan, "[OpenDatabase Nwind.mdb]"
DDEExecute Chan, "[OpenForm Employees,0,,,1,0]"
DDETerminate Chan
For more information about using Microsoft Access as a DDE server, search for "DDE," and then "Using Microsoft Access As a DDE Server" using the Microsoft Access Help menu.
Keywords : kbinterop
Version : 1.0 1.1 2.0 7.0
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: March 9, 1999