R
Rod
I'm trying to link a front end db to a table in a back end db. This is my
code...
'Creates link to table SpringfieldLetters in smpdata.mdb
Function fncLinkToSpringfieldLetters()
Dim strInternalTableName As String
Dim strExternalDB As String
Dim strExternalTable As String
Dim tdf As TableDef
Dim db As Database
Set db = CurrentDb()
strInternalTableName = "SpringfieldLetters"
strExternalTable = "SpringfieldLetters"
Set tdf = db.CreateTableDef(strInternalTableName)
tdf.Connect = ";DATABASE=" & "c:\lacc\smpdata.mdb"
tdf.SourceTableName = strExternalTable
db.TableDefs.Append tdf
End Function
When I run the function I receive the vb run-time error 3012: Object
"SpringfieldLetters" already exists.
If I change the name of the linked table to a distinct name, it works fine.
However, I want the linked table to have the same name as the back end table.
I tried a workaround...
DoCmd.CopyObject , "SpringfieldLetters", acTable, "SpringfieldLetters2"
trying to rename the linked table with the distinct name
"SpringfieldLetters2" to the name of the table in the back end db. I
received the vb run-time error 2501: The CopyObject action was canceled.
I'd appreciate your help!
Rod
code...
'Creates link to table SpringfieldLetters in smpdata.mdb
Function fncLinkToSpringfieldLetters()
Dim strInternalTableName As String
Dim strExternalDB As String
Dim strExternalTable As String
Dim tdf As TableDef
Dim db As Database
Set db = CurrentDb()
strInternalTableName = "SpringfieldLetters"
strExternalTable = "SpringfieldLetters"
Set tdf = db.CreateTableDef(strInternalTableName)
tdf.Connect = ";DATABASE=" & "c:\lacc\smpdata.mdb"
tdf.SourceTableName = strExternalTable
db.TableDefs.Append tdf
End Function
When I run the function I receive the vb run-time error 3012: Object
"SpringfieldLetters" already exists.
If I change the name of the linked table to a distinct name, it works fine.
However, I want the linked table to have the same name as the back end table.
I tried a workaround...
DoCmd.CopyObject , "SpringfieldLetters", acTable, "SpringfieldLetters2"
trying to rename the linked table with the distinct name
"SpringfieldLetters2" to the name of the table in the back end db. I
received the vb run-time error 2501: The CopyObject action was canceled.
I'd appreciate your help!
Rod