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

Help Reinterpreting code module

Status
Not open for further replies.

Kalisto

Programmer
Feb 18, 2003
997
GB
HI, Im not a vba / access bod, so apologies.

Ive got an access database, that Ive split.
This is going to be installed on a network.
Ive found the code below, which is says will update a table to its new link when called.

Ive created a table in my front end called configuration

So, how do I actually iterate throughthe table, so I can pull out the table names, and the location.

Or

Is there an easier way?

(I assume that as MS allows this to happen, that there may be a config setting or a key somewhere that can be set to the appropriate location?

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 = gdbs.CreateTableDef(strTable) 
   tdf.Connect = ';DATABASE=' & strDb 
   tdf.SourceTableName = strTable 

   '-- Add this TableDef to the current database. 
   gdbs.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

Cheers

K
 
Kalisto,

If this is a one off exercise you want to perform (rather than every time the database is opened) then I would use the Linked Table Manager from Tools>Database Utilites>Linked Table Manager.

Ed Metcalfe.

Please do not feed the trolls.....
 
Sorry Ed, It will happen quite a lot, so I'd rather just write the code..

 
Cheers, I got it working a while ago. My biggest issue, it appears is my typing :$
K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top