I know I've done this a long time a go. I'm trying to join this century and not use DAO. I pulled this right from the help files. I'm looping through all of the DBs in the directory and pulling the database creation date in the MsysObjects file. The looping is successful, but it crashes at the DDEExecute call.
Thanks!
Function AccessDDE(fname As String) As String
Dim intChan1 As Integer, intChan2 As Integer, strSQL As String, strDB As String
Dim strQueryData As String
On Error GoTo error2:
strDB = "[OpenDatabase " & fname & "]" ' Also tried without the brackets
intChan1 = DDEInitiate("MSAccess", "System")
DDEExecute intChan1, strDB ' crashes here - error 6 Overflow
strSQL = "SELECT MSysObjects.DateCreate, MSysObjects.Name FROM MSysObjects WHERE (((MSysObjects.Name)= """
strSQL = strSQL & "Databases """
strSQL = strSQL & ");"
' haven't got to test this part'
intChan2 = DDEInitiate("MSAccess", fname & ";" & " TABLE MSysObjects")
strQueryData = DDERequest(intChan2, strSQL)
AccessDDE = strQueryData
DDETerminate intChan2
' Close database.
DDEExecute intChan1, "[CloseDatabase]"
DDETerminate intChan1
error2: Debug.Print Err.Number, Err.Description
End Function
Thanks!
Function AccessDDE(fname As String) As String
Dim intChan1 As Integer, intChan2 As Integer, strSQL As String, strDB As String
Dim strQueryData As String
On Error GoTo error2:
strDB = "[OpenDatabase " & fname & "]" ' Also tried without the brackets
intChan1 = DDEInitiate("MSAccess", "System")
DDEExecute intChan1, strDB ' crashes here - error 6 Overflow
strSQL = "SELECT MSysObjects.DateCreate, MSysObjects.Name FROM MSysObjects WHERE (((MSysObjects.Name)= """
strSQL = strSQL & "Databases """
strSQL = strSQL & ");"
' haven't got to test this part'
intChan2 = DDEInitiate("MSAccess", fname & ";" & " TABLE MSysObjects")
strQueryData = DDERequest(intChan2, strSQL)
AccessDDE = strQueryData
DDETerminate intChan2
' Close database.
DDEExecute intChan1, "[CloseDatabase]"
DDETerminate intChan1
error2: Debug.Print Err.Number, Err.Description
End Function