linked tables and VBA, ISAM error

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
 
B

Brendan Reynolds

I suspect the problem is in the value of the strDatabase variable rather
than in the code you have posted here. It should look like
";DATABASE=path/name of MDB here". Perhaps you're missing the ";DATABASE=" ?
--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
S

Stefan

Yes,

That was the problem,
Thanks very much.

The linking now works as expected.

Best regards
Stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top