Option Compare Database   'Use database order for string comparisons
Option Explicit
Declare Function lstrcpy Lib "Kernel" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long
Declare Function GlobalAlloc Lib "Kernel" (ByVal wFlags As Integer, ByVal dwBytes As Long) As Integer
Declare Function GlobalFree Lib "Kernel" (ByVal hMem As Integer) As Integer
Declare Function GlobalLock Lib "Kernel" (ByVal hMem As Integer) As Long
Declare Function GlobalUnlock Lib "Kernel" (ByVal hMem As Integer) As Integer
    

Function DDE () As Variant
    
    Dim intGlobal As Integer
    Dim lpGlbAddress As Long
    Dim strExpression As String

    On Error GoTo ErrorDDE
    
    If Command$ = "" Then
        DDE = False
        Exit Function
    End If

    strExpression = Space$(128)

    intGlobal = CInt(Trim$(Command$))
    lpGlbAddress = GlobalLock(intGlobal)
    lpGlbAddress = lstrcpy(strExpression, lpGlbAddress)

    strExpression = RTrim$(strExpression)
    strExpression = Left$(strExpression, Len(strExpression) - 1)

    DDE = Eval(strExpression)

ExitDDE:
    intGlobal = GlobalUnlock(intGlobal)
    Exit Function

ErrorDDE:
    DDE = False
    MsgBox Error$, 16, "DDE in Access"
    Resume ExitDDE

End Function

