• Refresh Links (ADO) (2000 (9.4.4119 SR-1))

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Refresh Links (ADO) (2000 (9.4.4119 SR-1))

    • This topic has 5 replies, 3 voices, and was last updated 22 years ago.
    Author
    Topic
    #385932

    I am trying to refresh the links on some tables with the following code using ADO.

    Public Function RefreshLinks(vChangedSourceFile As String) As Boolean
    Dim catDB As ADOX.Catalog
    Dim tblLink As ADOX.Table

    Set catDB = New ADOX.Catalog

    ‘ Open a Catalog object on the database in which to refresh links.
    catDB.ActiveConnection = CurrentProject.Connection
    catDB.Tables.Refresh

    For Each tblLink In catDB.Tables
    ‘ Check to make sure table is a linked table.
    If tblLink.Type = “LINK” And Left(tblLink.Name, 2) = “dt” Then
    tblLink.Properties(“Jet OLEDB:Link Datasource”) = vChangedSourceFile
    tblLink.Properties(“Jet OLEDB:Create Link”) = True
    If Err Then
    RefreshLinks = False
    End If
    End If
    Next tblLink

    Set catDB = Nothing
    RefreshLinks = True

    End Function

    Running the function generates the following error message:

    Run-time error ‘-2147217887 (80040e21)’

    Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.

    When I check the table properties, only the first ‘dt’ table was modifed?

    Any clues/guesses as to why the code does not loop through all of the tables?

    Thanks,

    Viewing 0 reply threads
    Author
    Replies
    • #667727

      You’re trying to change you links to point to a different back end, right? Check each table to see if the “Jet OLEDB:Link Datasource” is an empty string. If not, it’s a linked table. You’re hitting an ADO error in there someplace, so you need to check the errors collection of the connection object. The easiest way is to declare an ADODB.Errors object and an ADODB.Error object in your declarations and then test for a Count >0 on the errors collection. Try this:

      Dim errCurr as ADODB.Error
      Dim ADOErrors as ADODB.Errors

      Set ADOErrors = Cat.ActiveConnection.Errors

      Then in your error handler, you can loop through them using the For each errCurr in ADOErrors syntax. Just make sure you issue an ADOErrors.Clear after then end of the For-Next loops because there is no automatic reset on ADO errors.

      • #667979

        When I used the error collection, I got the same error message as before.

        I know that all of the ‘dt’ tables are linked because I manually created the links.

    Viewing 0 reply threads
    Reply To: Refresh Links (ADO) (2000 (9.4.4119 SR-1))

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: