Public Sub LinkTabVse(PathToBase As String)
' ========= Прикрепляет все с помощью Public Sub LinkTab ========================
Dim DRDB As DAO.Database
Dim tdf As DAO.TableDef
Soobchitb = ""
On Error Resume Next
If Dir(PathToBase) <> "" Then
Set DRDB = OpenDatabase(PathToBase)
For Each tdf In DRDB.TableDefs
Call LinkTab(PathToBase, tdf.NAME)
Next tdf
Else
Soobchitb = Soobchitb & vbCrLf & "Путь не найден " & PathToBase
End If
DRDB.Close
Set DRDB = Nothing
End Sub
Public Sub LinkTab(Path_Base As String, Tabl_Name As String)
'=============Прикрепляет из указанной базы указану таблицу ================
If Left(Tabl_Name, 4) = "Msys" Then Exit Sub
Dim db As DAO.Database
Dim tdfs As DAO.TableDef
Set db = CurrentDb
On Error Resume Next
db.Execute "DROP TABLE " & Tabl_Name
Set tdfs = db.CreateTableDef(Tabl_Name)
tdfs.Connect = ";DATABASE=" & Path_Base
tdfs.SourceTableName = Tabl_Name
db.TableDefs.Append tdfs
dbs.Close
Set dbs = Nothing
End Sub
|