Results 1 to 2 of 2

Thread: link all tables

  1. #1
    Lounger
    Join Date
    Apr 2010
    Location
    Sofia
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a working code linking all table.I want to rearrange it so that the table "calls" is not linked.Can you help me? My code is the following:
    Public Function LinkAllTables(DBName)
    'link all user tables in source database
    Dim FrontDB As DAO.Database, BackDB As DAO.Database
    Dim Tbl As DAO.TableDef, Lnk As DAO.TableDef

    Set FrontDB = CurrentDb
    Set BackDB = OpenDatabase(DBName)

    For Each Tbl In BackDB.TableDefs
    If Tbl.Attributes = 0 Then
    Set Lnk = FrontDB.CreateTableDef( _
    Name:=Tbl.Name)
    Lnk.SourceTableName = Tbl.Name
    Lnk.Connect = ";DATABASE=" & BackDB.Name
    FrontDB.TableDefs.Append Lnk
    End If
    Next
    DoCmd.Beep
    End Function

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Pellin,

    This should do it.

    Quote Originally Posted by pelin View Post
    I have a working code linking all table.I want to rearrange it so that the table "calls" is not linked.Can you help me? My code is the following:
    Public Function LinkAllTables(DBName)
    'link all user tables in source database
    Dim FrontDB As DAO.Database, BackDB As DAO.Database
    Dim Tbl As DAO.TableDef, Lnk As DAO.TableDef

    Set FrontDB = CurrentDb
    Set BackDB = OpenDatabase(DBName)

    For Each Tbl In BackDB.TableDefs
    If Tbl.Attributes = 0 and Tbl.name <> "calls" Then
    Set Lnk = FrontDB.CreateTableDef( _
    Name:=Tbl.Name)
    Lnk.SourceTableName = Tbl.Name
    Lnk.Connect = ";DATABASE=" & BackDB.Name
    FrontDB.TableDefs.Append Lnk
    End If
    Next
    DoCmd.Beep
    End Function
    RG
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •