Refreshlink on Dataverse table from Access Database not working

  Kiến thức lập trình

I have a button on an Access form that calls the subroutine below. The database has external links to Dataverse tables. The idea of the routine is to refresh the links to the Dataverse tables and then refresh the form. The subroutine completes normally, and the “Tables Refreshed” message appears without error. However, the tables are not actually refreshed. The last table is called tblProjectsDataverse and contains project descriptions from the table which then appear in a list on the form. After I run the routine, I manually open the linked table (tblProjectsDataverse) and new projects added from a different source to the Dataverse table are not included. If I manually run Refresh Links by right clicking the linked table on the Navigation pane and selecting Refresh Links, the table is updated correctly. I don’t know why the .RefreshLink method in VBA would work differently than Refresh Link manually.

Private Sub cmdRefresh_Click()

Dim dbsCurrent As Database
Dim tbl As TableDef

Set dbsCurrent = CurrentDb

    For Each tbl In CurrentDb.TableDefs()
        If tbl.Attributes = dbAttachedTable Then
                
            If Right(tbl.Name, 9) = "Dataverse" Then
        
            MsgBox (tbl.Connect)
            MsgBox (tbl.Name)
            tbl.RefreshLink
            
            End If
            
        End If
                
    Next tbl
    
    Me.Refresh
    
    MsgBox ("Tables Refreshed")

End Sub

The two msgbox lines produces the following when the routine is run:

I’ve tried using the .RefreshLink method and the connection string seems to be correct according to what others have posted.

12

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT