Alex
It does work but only if the location of the BE has moved if the BE is still
in the same location then it does not refreh the link because its still at
the same location but the password has changed do you know how i can get
aroung that. I need it to refresh even if the BE table has not been moved
This is the code
Public Sub Startup()
On Error GoTo Startup_Err
Dim tdf As DAO.TableDef
Dim strD As String
Dim strC As String
Dim strFilename As String
Dim strIMEX As String
Dim db As DAO.Database
Set db = CurrentDb
Dim Pass As String
Pass = "markus0425"
MsgBox Pass
strD = getpath(db.Name) & "Tables\"
DoCmd.OpenForm "frmLinkingTables"
For Each tdf In CurrentDb.TableDefs
If Len(Nz(tdf.Connect, "")) > 0 Then ' non-local
If Right(tdf.Connect, 3) = "xls" Then
If InStr(tdf.Connect, strD) = 0 Then ' need to
reconnect
Forms!frmLinkingTables!lblTable.Caption = tdf.Name
strIMEX = Left(tdf.Connect, InStr(tdf.Connect,
"Database=") + 8)
strC = strIMEX & strD & tdf.Name & ".xls"
tdf.Connect = strC
tdf.RefreshLink
DoEvents
End If
Else
strFilename = getfile(Mid(tdf.Connect, 11))
If InStr(tdf.Connect, strD) = 0 Then ' need to
reconnect
Forms!frmLinkingTables!lblTable.Caption = tdf.Name
tdf.Connect = ";DATABASE=" & strD & strFilename &
";PWD=" & Pass
tdf.RefreshLink
End If
End If
End If
Next
DoCmd.Close acForm, "frmLinkingTables"
Startup_Exit:
Exit Sub
Startup_Err:
If Err.Number = 2450 Then 'form is missing
MsgBox "Cancelling Linking"
Resume Startup_Exit
Else
MsgBox Err.Description
Resume Startup_Exit
End If
End Sub