[AccessD] Fast back-end relinking?

Gustav Brock gustav at cactus.dk
Thu Jun 5 14:24:26 CDT 2003


Hi Christopher

Use RefreshLink:

        Set tbl = db.TableDefs(rsData("TableName"))
        tbl.Connect = ";DATABASE=" & rsData("Path")
        tbl.RefreshLink
        rsData.MoveNext

Also, for increased speed, open the backend before the loop and close
it when finished the loop.

/gustav


> First off:  I have seen (and used) Tribble's Back-End relinker
> before.  That's not what I need in this case.

> I have inherited an app with some back-end relinking code that is
> very slow.  I've seen programmatic implementations of a table link
> that linked up very quickly, as quickly as using File > Get External
> Data > Link Tables.  The one I'm dealing with takes many times as
> long.

> There is a table in my db called tblTable.  It contains the name and
> path of every table in the database.  The table is used in the
> following code:

> ***START***

> Dim db As DAO.Database
> Dim tbl As DAO.TableDef
> Set db = CurrentDb
> Dim rsData As DAO.Recordset


>     Set rsData = db.OpenRecordset("SELECT * FROM tblTable")
    
>     rsData.MoveFirst
    
>     Do Until rsData.EOF = True
>         Set tbl = db.CreateTableDef(rsData("TableName"))
>         Debug.Print "Now attaching " & tbl.Name & "..."
>         tbl.Connect = (";DATABASE=" & rsData("Path"))
>         tbl.SourceTableName = rsData("TableName")
>         db.TableDefs.Append tbl
>         rsData.MoveNext
>     Loop

> db.Close

> ***END***

> All the lag takes place when running the 'db.TableDefs.append tbl'
> line.

> Is there any way to speed this process up?  I've seen it done more
> quickly before, I just didn't get to see the actual code.  :(

> -Christopher-

> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com



More information about the AccessD mailing list