PC Review


Reply
Thread Tools Rate Thread

Changing Linked Tables through VBA code

 
 
=?Utf-8?B?SmVmZg==?=
Guest
Posts: n/a
 
      16th Feb 2005
Hello,

Is there a way ot chane Linked Tables through VBA code
rather than having to go the Linked Table Manager ?

Any help would be greatly appreciated.

Thank you,
Jeff
 
Reply With Quote
 
 
 
 
Sean
Guest
Posts: n/a
 
      16th Feb 2005
Here is a sample from in invoicing database I wrote that does just what you are asking.

I keep each month's invoices in a .MDB data file located in the "p:\invoices\" folder, each containing one month's information. The front end database has a linked table called "tInvoiceDetail". Depending on which month the user wishes to work with, I relink that table to the appropriate ..MDB using this procedure.

I use Access 2000. This function is depended on having the "Microsoft ADO Ext. 2.x for DLL and Security" (MSADOX.DLL) reference.

Sub RelinkTable(strFilename As String)

Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table

Set cat = New ADOX.Catalog
Set cat.ActiveConnection = CurrentProject.Connection
If cat.Tables("tInvoice Detail").Properties("JET OLEDB:Link Datasource") <> ("p:\invoices\" & strFilename) Then
cat.Tables.Delete ("tInvoiceDetail")

Set tbl = New ADOX.Table
tbl.Name = "tInvoiceDetail"
tbl.ParentCatalog = cat
tbl.Properties("Jet OLEDB:Create Link") = True
tbl.Properties("Jet OLEDB:Link Datasource") = "p:\invoices\" & strFilename
tbl.Properties("Jet OLEDB:Remote Table Name") = "tInvoiceDetail"
cat.Tables.Append tbl
Set tbl = Nothing
End If
Set cat = Nothing

End Sub

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      16th Feb 2005
In addition to Sean's suggestion, check
http://www.mvps.org/access/tables/tbl0009.htm at "The Access Web"

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Jeff" <(E-Mail Removed)> wrote in message
news:43DEBB9C-DA50-4B3D-AB22-(E-Mail Removed)...
> Hello,
>
> Is there a way ot chane Linked Tables through VBA code
> rather than having to go the Linked Table Manager ?
>
> Any help would be greatly appreciated.
>
> Thank you,
> Jeff



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Linked Tables in code - Permissions vbcraft Microsoft Access 5 18th Sep 2009 12:12 PM
VBA code for searching and appending data from linked tables to unlinked tables Pete Straman Straman via AccessMonster.com Microsoft Access External Data 1 17th Feb 2005 07:40 PM
Changing paths of linked tables without Linked Table Manger Ilka Microsoft Access Database Table Design 0 30th Jul 2003 01:43 AM
changing linked tables Steve Microsoft Access External Data 1 16th Jul 2003 08:07 AM
Re: changing linked tables Cheryl Fischer Microsoft Access External Data 0 15th Jul 2003 01:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:58 PM.