Hi All
I've read all the posts on Linking tables and found no solution to my problem. Would be grateful if someone could help.
I have a FE database linked to many BE databases. I'm concerned with only 2 tables in one of my BEs.
tblCourses
tblStudents
each table contains data within for an academic year.
Each table is static and should never be renamed or moved from one of two databases.
05.mdb
06.mdb
i.e. there is a tblCourses in both 05.mdb and 06.mdb with different data.
I have a form with a list box containing the following values:-
2005/2006
2006/2007
When the user selects 2005/2006 it links the tables to 05.mdb likewise when the user selects 2006/2007 it links these 2 tables to 06.mdb.
I would have thought this was really easier - without having to write pages and pages of code?!?
The nearest I have got is the following code:
Dim dbsTemp As Database
Dim tdfLinked As TableDef
Dim strTable As String
Dim strConnect As String
Dim strSourceTable As String
Set dbsTemp = CurrentDb
'Fill in the name of the link
strTable = "tblCourses"
'Fill in the path of the database you want to link to
If FindAcadYear = "2005/2006" Then
strConnect = "\\server\share\05_BE.mdb"
ElseIf FindAcadYear = "2006/2007" Then
strConnect = "\\server\share\06_BE.mdb"
End If
'Fill in the name of the table you want to link to
strSourceTable = "tblQLCourses"
Set tdfLinked = dbsTemp.CreateTableDef(strTable)
tdfLinked.Connect = ";DATABASE=" & strConnect
tdfLinked.SourceTableName = strSourceTable
dbsTemp.TableDefs.Append tdfLinked
But all this does is say the table already exists. I don't want to use the Linked Table Manager and I don't want to have to delete the tables first.
Thanks & Regards
I've read all the posts on Linking tables and found no solution to my problem. Would be grateful if someone could help.
I have a FE database linked to many BE databases. I'm concerned with only 2 tables in one of my BEs.
tblCourses
tblStudents
each table contains data within for an academic year.
Each table is static and should never be renamed or moved from one of two databases.
05.mdb
06.mdb
i.e. there is a tblCourses in both 05.mdb and 06.mdb with different data.
I have a form with a list box containing the following values:-
2005/2006
2006/2007
When the user selects 2005/2006 it links the tables to 05.mdb likewise when the user selects 2006/2007 it links these 2 tables to 06.mdb.
I would have thought this was really easier - without having to write pages and pages of code?!?
The nearest I have got is the following code:
Dim dbsTemp As Database
Dim tdfLinked As TableDef
Dim strTable As String
Dim strConnect As String
Dim strSourceTable As String
Set dbsTemp = CurrentDb
'Fill in the name of the link
strTable = "tblCourses"
'Fill in the path of the database you want to link to
If FindAcadYear = "2005/2006" Then
strConnect = "\\server\share\05_BE.mdb"
ElseIf FindAcadYear = "2006/2007" Then
strConnect = "\\server\share\06_BE.mdb"
End If
'Fill in the name of the table you want to link to
strSourceTable = "tblQLCourses"
Set tdfLinked = dbsTemp.CreateTableDef(strTable)
tdfLinked.Connect = ";DATABASE=" & strConnect
tdfLinked.SourceTableName = strSourceTable
dbsTemp.TableDefs.Append tdfLinked
But all this does is say the table already exists. I don't want to use the Linked Table Manager and I don't want to have to delete the tables first.

Thanks & Regards