Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tough one: Macro to pass data from access to excel

Status
Not open for further replies.

JoBlink

Technical User
May 28, 2004
38
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top