Help with link code please...

edp1959

Registered User.
Local time
Today, 08:52
Joined
Aug 24, 2003
Messages
23
I have a FE database that on initial setup the user will enter the drive letter of the mapped location where the BE resides. The FE will then update all the linked tables to that path. This should work but for some reason the FE locks up (stops responding) when I test this. Any suggestions as to why. It doesn't stop responding until this part of the code:

tdf.Refreshlink

I have looked and it does change the link path, but it locks up.

Dim dbs As DAO.database
Dim dataPath As String
Dim tdf As DAO.TableDef
dataPath = Me.drive & ":\IMP1_R2.2_be.mdb"
For Each tdf In dbs.TableDefs
'Not a MSys type table
'If the table has a connect string, it's a linked table.
If Len(tdf.Connect) > 0 Then
If InStr(tdf.name, "MSys") = 0 Then
tdf.Connect = ";DATABASE=" & dataPath
End If
err = 0
On Error Resume Next
tdf.RefreshLink
End If
Next tdf
DoCmd.Echo True, "Done"
 
Instead of tdf.RefreshLink, use a TransferDatabase command, like so:

DoCmd.TransferDatabase acLink, "Microsoft Access", strLinkTo, acTable, strSourceTableName, strDestTableName

Look up the TransferDatabase command in Access Help if you need better descriptions than what I've provided.

That should do it.
 

Users who are viewing this thread

Back
Top Bottom