VBA, MS Access MS Access в примерах

Удаление связи между таблицами средствами VBA (DAO)

По материалам: https://www.cyberforum.ru/ms-access/thread2586700.html

Public Sub DeleteRelation(tblName As String)
    Dim rel As DAO.Relation
    Dim dbs As DAO.Database
    
    Set dbs = CurrentDb
    With dbs
        For Each rel In .Relations
            With rel
                If tblName = .Table Or tblName = .ForeignTable Then
                    Debug.Print .Name, .Table, .ForeignTable
                    dbs.Relations.Delete .Name
                End If
            End With
        Next
    End With
End Sub
Назад ToTop
L.E. 06.02.2024
Рейтинг@Mail.ru