Create a linked table with VBA
Posted by: fredometro on
Feb 1st, 2004 |
Filed under: MS-Access
Usually we would just need to refresh the existing linked tables, but in some cases, it is necessary to create a linked table from scratch.
This is useful when linking a text file or Excel sheet which name changes over the time.
public sub ReconnectTable(sTable, sConnect)
Dim db as Database
Dim td As TableDef
on error goto Err_Reconnect
Set db = currentdb()
on error resume next
‘ Delete the table
db.TableDefs.Delete sTable
on error goto Err_Reconnect
‘ Create the table def.
Set td = db.CreateTableDef(sTable)
‘ Connect the table
td.Connect = “;DATABASE=” & sConnect & “;”
‘ Set the source table name
td.SourceTableName = sTable
‘ Add the table def to the tabledefs collection
db.TableDefs.Append td
‘ refresh the link
td.RefreshLink
db.close
exit sub
Err_Reconnect:
msgbox “Error while reconnecting table ” & sTable & “: ” & error$
end sub


December 12th, 2009 at 8:28 am
Coeds Need Cash
December 12th, 2009 at 8:29 am
Anime Porn
December 12th, 2009 at 8:30 am
Kelly Summer
December 12th, 2009 at 8:31 am
Porn Is An Act
December 12th, 2009 at 8:32 am
Cornhole Cruisers
December 12th, 2009 at 8:33 am
Full Screen Teen
December 12th, 2009 at 8:34 am
Cute Teen Pink
December 12th, 2009 at 8:35 am
Victoria Redd
December 12th, 2009 at 8:37 am
Teen Deja
December 12th, 2009 at 8:38 am
We Fuck Babysitters
December 12th, 2009 at 8:39 am
Water Bondage
December 12th, 2009 at 8:40 am
Cindy 8teen
December 12th, 2009 at 8:41 am
123 Nikki Nite
December 12th, 2009 at 8:42 am
Sara Cutie
December 12th, 2009 at 8:43 am
Tiny Miley
Add A Comment
You must be logged in to post a comment.