AngelsGuardian
Registered User.
- Local time
- Yesterday, 19:02
- Joined
- Jan 23, 2005
- Messages
- 42
I have been searching for a long time for codes to do that but everytime, i get some verry long coding to do or it just doesnt work at all. BUyesterday, i have found that little piece of code that does a realy good job...
The only prob i have with it is that i have near 15 tables to update from different sources. I tought about doing a local table with all the tables names and loop trough it to make sure they are all there and linked but....
I can't figure out how
I am doing this because the IS departement tends to move things around and if they change the DBs from one place to another... i dont want to have to come here and redo the links on the original FrontEnd, compile and redistribute (/me lazy and i know it). I want people to just point to the asked DB and there you go.
I hope i was clear enough !!!
Code:
Sub LinkTable(strTable As String, strDb As String)
Const LT_LINKEDALREADY As Integer = 3012
Dim tdf As TableDef
On Error GoTo Err_LinkTable
'-- Create a new TableDef then link the external table to it
Set tdf = CurrentDb.CreateTableDef(strTable)
tdf.Connect = ";DATABASE=" & strDb
tdf.SourceTableName = strTable
'-- Add this TableDef to the current database.
CurrentDb.TableDefs.Append tdf
Exit_LinkTable:
Exit Sub
Err_LinkTable:
If Err.Number = LT_LINKEDALREADY Then
'-- Do nothing - the table's linked in already
Resume Exit_LinkTable
Else
'-- Put some code here to handle this error
End If
End Sub
The only prob i have with it is that i have near 15 tables to update from different sources. I tought about doing a local table with all the tables names and loop trough it to make sure they are all there and linked but....
I can't figure out how
I am doing this because the IS departement tends to move things around and if they change the DBs from one place to another... i dont want to have to come here and redo the links on the original FrontEnd, compile and redistribute (/me lazy and i know it). I want people to just point to the asked DB and there you go.
I hope i was clear enough !!!