linked table refresh links requires restart

xaviermobius

Registered User.
Local time
Today, 11:42
Joined
Jul 25, 2006
Messages
12
I am using the following code to refresh the linked tables with the backend, the code works fine except that after the table links get refreshed (following a change in where the program is stored) a restart of the application is necessary.

Code:
Sub TabloLinkleriniKontrolEt()
    Dim daTaban As Database, tbTablo As TableDef
    Set daTaban = CurrentDb

    For Each tbTablo In daTaban.TableDefs

        If InStr(tbTablo.Connect, "DATABASE=") > 0 Then
            Debug.Print tbTablo.Connect

            If tbTablo.Connect <> ";DATABASE=" & CurrentProject.Path & "\_ BACKEND\ivrb_be.mdb" Then
                tbTablo.Connect = ";DATABASE=" & CurrentProject.Path & "\_ BACKEND\ivrb_be.mdb"
                tbTablo.RefreshLink
            End If
        End If
    Next
End Sub

So... following a move of the application and therefore an update of the links an application restart is required.

I have tried using a me.requery to circumvent this problem, but with no luck.... any suggestions?

thx.
 
I normally delete then add a new one using append


if table exists with the link you want to change then delete it then run the following code

Set db = CurrentDb



' Create a new table object
Set tdf = db.CreateTableDef(strTableName)

'Set the appropriate properties to make it a linked table
tdf.Connect = ";DATABASE=" & strDatabase
tdf.SourceTableName = strSourceTable

' Save the new table
db.TableDefs.Append tdf
 

Users who are viewing this thread

Back
Top Bottom