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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to refresh a linked table in vba

Status
Not open for further replies.

Dreamwalker

Programmer
Apr 30, 2002
43
US
Hey there ...


I know it can be done with VBA coding ... with the .refresh property ... tho I cant figure out how to say
ThisTable.Refresh... to make it refresh the data from the 1st database wich is on my network ...

Thanks for the help
Vince
 
Thanks anyways I found it ;))

You may need it someday so here is the code

1st Create a RefreshLink function

Function RefreshLink(strTable As String, strSourceDB As String)

Dim ws As Workspace
Dim db As Database
Dim tdf As TableDef

Set ws = DBEngine.Workspaces(0)
Set db = CurrentDb()
Set tdf = db.TableDefs(strTable)
' specify new location of source table
tdf.Connect = ";DATABASE=" & strSourceDB
' refresh the link
tdf.RefreshLink

End Function

2nd Call it on the opening of the dbase
Call RefreshLink("TABLENAME", "C:\MYPATH")

Note : One good thing is if you do it via VBA you dont need to give users permissions it will be updated autotically

Cheers
Vince
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top