Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    RefreshLinks (Access 2000)

    I have copied from this forum a function called RefreshLinks. It should relink the tables
    in the path "C:bebe.mdb ". I have made a button on the form and on the OnClick event
    i have put the following
    RereshLinks( "C:bebe.mdb ")

    However nothing happens.If i deliberately delete the links in the database, then
    after pressing the button the tables in the back end database with a path ( "C:bebe.mdb ") are not relinked. I am afraid i do not either understand the
    nature of the function, or i do not use it properly. May i receive some information and help as to how should i use this function ?

    The function i have copied and pasted from the Forum is the following :

    Function refreshlinks(strFileName As String) As Boolean
    Dim tdf As DAO.TableDef
    On Error Resume Next
    ' Loop through all tables in database.
    For Each tdf In CurrentDb.TableDefs
    ' If the Connect property is non-empty, the table is linked
    If Len(tdf.Connect) > 0 Then
    tdf.Connect = ";DATABASE=" & strFileName
    Err.Clear
    tdf.RefreshLink ' Re-link the table.
    If Err Then
    refreshlinks = False
    Exit Function
    End If
    End If
    Next tdf
    Set tdf = Nothing
    refreshlinks = True ' All links have been refreshed.
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: RefreshLinks (Access 2000)

    Does strFileName include the full path to the table source, including the drive letter? Are you passing a *different* table source into the routine? I use a similar routine in a class to manage table links and it works just fine. As long as the links are valid, nothing should happen. It's only if the value passed in is different that something should occur. Are you saying that doesn't happen?

    The RefreshLink method doesn't relink the table--that's what setting the connect property does. RefreshLink updates the connection information so you can actually use the table. If you delete a link, there is nothing to relink because the table no longer exists and won't show up in the tabledefs collection. Perhaps if you explain what you're trying to accomplish we can be of more help.
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: RefreshLinks (Access 2000)

    Thank you for your information. Sometimes i copy the whole database into another position, and then
    rename the database again. Is it useful in this case to use the function RefreshLinks, so to keep my tables
    in order ? So in few words what is the advantage for me if i add on the RefreshLink function into my
    normal everyday procedures of copying and renaming the databases?

    Please accept my best regards

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: RefreshLinks (Access 2000)

    It depends on what you're copying and renaming. If the tables are the same in the copied database, then refreshlinks could be used to change the links to the new location. If the tables are different, then it serves no purpose because you will have to delete the links and manually create links to the new table names.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •