Access 2k Linking Tables in Code

  • Thread starter Thread starter PatrickR212
  • Start date Start date
P

PatrickR212

Guest
Hi All,

I read previous posts on automatically relinking FE to BE but the code doesn't seem to work in Access2K. Does anyone have any code to share that can do this in A2K?

The application will be distributed to private users so the directory structure will vary. I was planning on having the code search for the Path of the current database (FE) and reconnect the BE.

Any help is appreciated.

Thanks,

Patrick
 
This is the standard code I use to link:

Dim db as DAO.Database
Dim tbl as DAO.Tabledef
Dim strPath as String

strPath=Path & name of backend

Set db=CurrentDb

Set tbl=db.CreateTableDef("Name given to table")

tbl.Connect=";DATABASE=" & strPath

tbl.SourceTableName="Name of backend table"

db.TableDefs.Append tbl

Set tbl=Nothing
Set db=Nothing


If the path to the backend will vary you'll need to write a sub to determine the path.
 
Rob,

Thank you. Your code worked great when I took out the following lines:

Dim db As DAO.Database
Dim tbl As DAO.Tabledef

Any ideas why this is? Does A2K accept the "TableDef" type? That's what kept giving me compile errors in my previous attempts.

I didn't have to use any replacement DIM statements. I thought this would give errors but it worked fine. Any thoughts?

Thank you,

Patrick
 
Pat,

Thank you for your reply. I can see how this impacts the code as well as other sample code I've seen. I think I'll need to spend some time researching ADO and DAO and the properties of each.

Thanks again,

Patrick

PS
CT neighbor here. I'm in Milford. ;)
 

Users who are viewing this thread

Back
Top Bottom