Click to See Complete Forum and Search --> : Using the CreateTableDef Method of Access97 with an attached table


Ebi
February 29th, 2000, 12:10 PM
Hello. I just read my last posting and noticed that it wasn't very understandable at all. So I try to explain it again with some other words. Really hope you can help me since it is very important to me to got this running.

I'm converting an Access 2.0-Database to an Access 97 Database.

Initialisation work done before calling the function:

set ws = DBEngine.Workspaces(0)
dbname="C:\test.mdb" 'thats the database containing the table I want to attach
dbtable="addresses" 'Thats an existing attached table in the current database




The Function of the 2.0-Version looked like this, worked properly and was called with the arguments(ws,dbtable,dbname,""):

private Function mbDbConnectTbl (ws as WorkSpace, sTbl as string, sDatabase as string, sManPath as string) as Integer

Dim db as Database
Dim td as TableDef
Dim sConnect as string

set db = ws.Databases(0)
db.TableDefs.Delete sTbl

sConnect = sDatabase
sConnect = ";DATABASE=" & sConnect

set td = db.CreateTableDef(sTbl, DB_ATTACHEDTABLE, sTbl, sConnect)

db.TableDefs.Append td

mbDbConnectTbl = true
End Function



The value of the constant DB_ATTACHEDTABLE is equal to dbAttachedTable in Access 97

When I try to call

set td = db.CreateTableDef(sTbl, dbAttachedTable, sTbl, sConnect)



In Access 97 there is the error message 3001 "invalid argument". If I remove the dbAttachedTable argument that function is running properly but there is the error message 3264 "No field defined -- cannot append tabledef or index" at the next line

db.TableDefs.Append td



.
I don't know how to solve this problem. I don't want to make big changes to the code since I want to be sure that the new Access 97 database is working in the same way as the Access 2.0-Version did.

Thank you very much,
Ebi