Copy TableDef from one DB to another

TKnight

Registered User.
Local time
Today, 16:56
Joined
Jan 28, 2003
Messages
181
Hi,

I am in the process of adding a couple of extra bits to Bob Larsons extremely useful FE auto update utility and have got a bit stuck on something relatively simple but I can't find any good examples for the code I need because strictly speaking it's bad practise to dymamically link tables I guess.

Basically, from within db_A I would like to create a linked table from db_B to db_C if possible. (B and C are the BE and FE of a split DB)

I have read around the subject a bit and it seems the simplest way to do it is probably to link from db_B into db_A using TransferDatabase which I managed no problem.

Now I guess I need to copy the TableDef properties for the linked table from db_A to db_C which should just copy the link if i'm correct?

If anyone could give me a sample bit of code to do this (or to create a link directly from db_B to db_C) id be really grateful.

Thanks in advance,

Tom
 
Which updater are you referring to? Would you provide a link?

See:

Relink Access tables from code

You will need to change the CurrentDB to open the front end database where you want to create the linked tables.
 
Last edited:
After going through the code in the link and putting together some other bits and pieces I found the simplest way to do this is below:

Code:
  Set dbs = DBEngine(0).OpenDatabase([I]PathToMyFE[/I])
  Set tdf = dbs.CreateTableDef("Table1")
  tdf.Connect = ";Database=" & [I]PathToMyBE[/I]
  tdf.SourceTableName = "Table1"
  dbs.TableDefs.Append tdf

just in-case anyone needs to do something similar...
 

Users who are viewing this thread

Back
Top Bottom