why tough?
because this event has to run randomly. Excel has DDE link updating sells at random intervals. I have a macro that is triggered every time data comes in. Within that macro I want to write the code to export updated values from Excel into Microsoft Access.
The problem was establishing connection link from Excel to access. Below is the macro triggered by updates as well as nonworking code for opening data links.
Of been working for two weeks surged into an up-and-down and this is my last resort. All help would be greatly appreciated. Thank you
-----------------------------------------
'data update activated code
Sub linktest()
'ActiveWorkbook.SetLinkOnData (MsgBox("Update"))
Dim Links As Variant
' Obtain an array for the links to Excel workbooks
' in the active workbook.
Links = ActiveWorkbook.LinkSources(xlOLELinks)
' If the Links array is not empty, then open each
' linked workbook. If the array is empty, then
' display an error message.
If Not IsEmpty(Links) Then
For i = 1 To UBound(Links)
ActiveWorkbook.SetLinkOnData Links(i), "LinkChange"
Next i
Else
MsgBox "This workbook does not contain any links " & _
"to other workbooks"
End If
End Sub
-----------------------------------------------
Sub LinkChange()
'CODE FOR PASSING DATA GOES HERE
End Sub
---------------------------------------------
'non-working code, opens access database but
'fails to pass data
Sub AddNewCustomer()
Chan = DDEInitiate("MSACCESS", "NORTHWIND;SQL SELECT AddNewCust(""TADO"",""Tad's Place"") FROM None;")
Result = DDERequest(Chan, "FirstRow")
Msgbox str(result(1))
DDETerminate Chan
End Sub
because this event has to run randomly. Excel has DDE link updating sells at random intervals. I have a macro that is triggered every time data comes in. Within that macro I want to write the code to export updated values from Excel into Microsoft Access.
The problem was establishing connection link from Excel to access. Below is the macro triggered by updates as well as nonworking code for opening data links.
Of been working for two weeks surged into an up-and-down and this is my last resort. All help would be greatly appreciated. Thank you
-----------------------------------------
'data update activated code
Sub linktest()
'ActiveWorkbook.SetLinkOnData (MsgBox("Update"))
Dim Links As Variant
' Obtain an array for the links to Excel workbooks
' in the active workbook.
Links = ActiveWorkbook.LinkSources(xlOLELinks)
' If the Links array is not empty, then open each
' linked workbook. If the array is empty, then
' display an error message.
If Not IsEmpty(Links) Then
For i = 1 To UBound(Links)
ActiveWorkbook.SetLinkOnData Links(i), "LinkChange"
Next i
Else
MsgBox "This workbook does not contain any links " & _
"to other workbooks"
End If
End Sub
-----------------------------------------------
Sub LinkChange()
'CODE FOR PASSING DATA GOES HERE
End Sub
---------------------------------------------
'non-working code, opens access database but
'fails to pass data
Sub AddNewCustomer()
Chan = DDEInitiate("MSACCESS", "NORTHWIND;SQL SELECT AddNewCust(""TADO"",""Tad's Place"") FROM None;")
Result = DDERequest(Chan, "FirstRow")
Msgbox str(result(1))
DDETerminate Chan
End Sub