title: Link multiple tables from one database
body: <p>I have actually this little function working as supposed:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Function createAttached(strTable As String, strPath As String, strBaseTable As String) As Boolean
      On Error GoTo CreateAttachedError
  
      Dim tdf As TableDef
      Dim strConnect As String
      Dim fRetval As Boolean
      Dim myDB As Database
  
      DoCmd.SetWarnings False
  
      Set myDB = CurrentDb
      Set tdf = myDB.CreateTableDef(strTable)
  
      With tdf
          .Connect = ";DATABASE=" &amp; strPath
          .SourceTableName = strBaseTable
      End With
  
      myDB.TableDefs.Append tdf
      myDB.TableDefs.Refresh
  
      fRetval = True
  
      DoCmd.SetWarnings True
  
  CreateAttachedExit:
      createAttached = fRetval
      Exit Function
  
  CreateAttachedError:
      If Err = 3110 Then
          Resume CreateAttachedExit
      Else
          If Err = 3011 Then
              Resume Next
          Else
              If Err = 3012 Then
                  Set tdf = myDB.TableDefs(strTable)
                  tdf.Connect = ";DATABASE=" &amp; strPath
                  tdf.RefreshLink
                  fRetval = True
                  GoTo CreateAttachedExit
              End If
          End If
      End If
  End Function
  </code></pre>
  
  <p>This code works fine, I can call the function as many times as I want to add links to tables from another database. However, I have about 30 tables to import from the same database and this script restarts from scratch everytime I call it. Because the database is located on another server, it takes about 1 min to link the 30 tables.</p>
  
  <p>Is there anything I could do with that function to make it work faster when I need to link multiple tables from the same database? I would like it to work with multiple strTable and strBaseTable in parameters instead of one (maybe arrays?), but I don't know how to do this.</p>
  
  <p>Thank you.</p>