Article ID: 128811
Article Last Modified on 1/19/2007
Private Sub Command1_Click()
Const LINK_MANUAL = 2, LINK_NONE = 0
Dim Cmd
' Create a string containing a Microsoft Access macro command.
Cmd = "[OPENDATABASE ""C:\MSOFFICE\ACCESS\SAMPLES\NorthWind.MDB""]"
NOTE: The sample database is called NWIND.MDB in versions 1.1
and 2.0.
If AppItems.LinkMode = LINK_NONE Then
' Set the DDE server application and topic to MSACCESS|SYSTEM.
AppItems.LinkTopic = "MSACCESS|SYSTEM"
' Specify the information passed to the AppItems text box.
AppItems.LinkItem = "SysItems"
' Set the LinkMode to a valid non-zero setting which causes
' Visual Basic to initiate a link to the program defined in
' the LinkTopic. The LINK_MANUAL constant value of 2 ensures
' that the link is not updated until the LinkRequest method
' is invoked.
AppItems.LinkMode = LINK_MANUAL
' Update the contents of the AppItems text box.
AppItems.LinkRequest
' Run a valid DDE operation for Microsoft Access, such as
' opening the sample database NorthWind.MDB.
AppItems.LinkExecute Cmd
If DBItems.LinkMode = LINK_NONE Then
' Set the DDE Server and topic to MSACCESS|NorthWind.
DBItems.LinkTopic = "MSACCESS|NorthWind"
' Pass a list of Microsoft Access tables to DBItems text box.
DBItems.LinkItem = "TableList"
' Set the LinkMode to update the DBItems text box only when the
' LinkRequest method is invoked.
DBItems.LinkMode = LINK_MANUAL
' Update the contents of the DBItems text box.
DBItems.LinkRequest
'Close the DDE link for the DBItems text box.
DBItems.LinkMode = LINK_NONE
End If
' Run a valid DDE operation for Microsoft Access, such as
' closing the sample database NorthWind.MDB.
AppItems.LinkExecute "[CloseDatabase]"
' Close the DDE link for the AppItems text box.
AppItems.LinkMode = LINK_NONE
End If
End Sub
Keywords: kbinfo kbinterop kbprogramming KB128811