Hi John,
When linking tables, to improve performance 100%+ during linking,
link your first table and straight after open that table and leave it open,
link all your other tables, then close the first table, because you have a
connection to the back-end it speeds up the process of linking the other
tables. By the way my code is using ADO not DAO for linking. Have one table
in the front-end that has the location of the backend db in a field so that
you can relink easer.
dim strBEDatabase as string
Dim bolGood As Boolean
Dim adoTest As New adoDB.Recordset
strBEDatabase = "c:\mybe.mdb"
bolGood = RelinkTable("Adverts", "Adverts", strBEDatabase)
With adoTest
If .State = adStateOpen Then
.Close
End If
.Open "Select * from ADVERTS", CurrentProject.Connection,
adOpenDynamic, adLockOptimistic
End With
bolGood = RelinkTable("Applicants", "Applicants", strBEDatabase)
....
adoTest.Close
Function RelinkTable(strTable As String, strSourceTable As String,
strSourceDB As String) As Boolean
On Error GoTo Err_RelinkTable
Dim adocat As New ADOX.Catalog
Dim adotbl As New ADOX.TABLE
Set adocat = New ADOX.Catalog
Set adocat.ActiveConnection = CurrentProject.Connection
Set adotbl.ParentCatalog = adocat
On Error Resume Next
adocat.Tables.Delete strTable
On Error GoTo Err_RelinkTable
adotbl.NAME = strTable
adotbl.Properties("Jet OLEDB:Link Datasource") = strSourceDB
adotbl.Properties("Jet OLEDB:Link Provider String") = "MS Access"
adotbl.Properties("Jet OLEDB:Remote Table Name") = strTable
adotbl.Properties("Jet OLEDB:Create Link") = True
adocat.Tables.Append adotbl
Exit_RelinkTable:
Exit Function
Err_RelinkTable:
If Err.Number = -2147217860 Then
Exit Function
Else
DisplayError "ModTableFuncs", "RelinkTable", Err.Description,
Err.Number, Erl
Resume Next
End If
End Function
Hope it helps.