S
stefan
Hello,
I created some code to creat a link to another mdb-
database. Now whenn the code is executed I get an ISAM-
error. After looking for this on the WWW I found only
that this has something to do with import from other
database programs. So not from access. Can anyone tell me
what is wrong with this code?
Public Sub CheckTablesInDatabase(strDatabase As String,
strTableNames As String)
'strDatabase is the database where the tables are
located
'strTableNames is a query containing all table-names
in the database to connect to
Dim dbs As Database
Dim rstTables As Recordset
Dim tdf As TableDef
Dim qryDefinition As String, strTabel As String
Dim TDName As Variant, TDAttributes As Long,
TDSourceTableName As Variant, TDConnect As Variant
'Query for all projects
'Take List of projects needed
strTabel = CurrentDb.QueryDefs(strTableNames).SQL
Set dbs = CurrentDb()
Set rstTabel = dbs.OpenRecordset(strTabel)
'add all tables as a link to the database
Do While Not rstTabel.EOF
TDName = rstTabel.Fields("Projectname")
TDAttributes = 0
TDSourceTableName = rstTabel.Fields("Projectname")
TDConnect = strDatabase
Set tdf = dbs.CreateTableDef(TDName,
TDAttributes, TDSourceTableName, TDConnect)
dbs.TableDefs.Append tdf
Loop
rstTabel.Close
dbs.Close
End Sub
I created some code to creat a link to another mdb-
database. Now whenn the code is executed I get an ISAM-
error. After looking for this on the WWW I found only
that this has something to do with import from other
database programs. So not from access. Can anyone tell me
what is wrong with this code?
Public Sub CheckTablesInDatabase(strDatabase As String,
strTableNames As String)
'strDatabase is the database where the tables are
located
'strTableNames is a query containing all table-names
in the database to connect to
Dim dbs As Database
Dim rstTables As Recordset
Dim tdf As TableDef
Dim qryDefinition As String, strTabel As String
Dim TDName As Variant, TDAttributes As Long,
TDSourceTableName As Variant, TDConnect As Variant
'Query for all projects
'Take List of projects needed
strTabel = CurrentDb.QueryDefs(strTableNames).SQL
Set dbs = CurrentDb()
Set rstTabel = dbs.OpenRecordset(strTabel)
'add all tables as a link to the database
Do While Not rstTabel.EOF
TDName = rstTabel.Fields("Projectname")
TDAttributes = 0
TDSourceTableName = rstTabel.Fields("Projectname")
TDConnect = strDatabase
Set tdf = dbs.CreateTableDef(TDName,
TDAttributes, TDSourceTableName, TDConnect)
dbs.TableDefs.Append tdf
Loop
rstTabel.Close
dbs.Close
End Sub