first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

Code: Procedures for Linked Tables

Public Sub basRenLinkTbls() ' 'This Sub removes the 'dbo_' prefix from linked Tables. ' Dim DAOTblDef As DAO.TableDef

With Application

    For Each DAOTblDef In CurrentDb.TableDefs
        If VBA.InStr(1, DAOTblDef.Name, "dbo_", _
            vbTextCompare) > 0 Then
            DAOTblDef.Name = VBA.Mid$(DAOTblDef.Name, 5)
        End If
    Next
    
    .CurrentDb.TableDefs.Refresh
    .RefreshDatabaseWindow
    
End With

End Sub

Public Sub basRemoveLinkedTbls() ' 'This Sub removes all linked Tables where a linked table 'is defined as a TableDef with a Connect property. ' Dim DAOTblDef As DAO.TableDef

With Application

    For Each DAOTblDef In CurrentDb.TableDefs
        If VBA.Len(DAOTblDef.Connect) > 0 Then _
            Call Application.DoCmd.DeleteObject(acTable, _
                DAOTblDef.Name)
    Next
    
    .CurrentDb.TableDefs.Refresh
    .RefreshDatabaseWindow
    
End With

End Sub

mod date: 1999-12-13T06:23:25.000Z