Changing the File Path on Linked Tables
Kod:
Function RelinkTables()
Dim dbs As Database
Dim tdf As TableDef
Dim ConStr, Oncesi, Sonrasi
' Loop through all tables in the database.
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
' If the table has a connect string, it's a linked table.
If Len(tdf.Connect) > 0 Then
ConStr = tdf.Connect
If InStr(1, tdf.Connect, "DATABASE=") > 0 Then
Oncesi = Left(ConStr, InStr(1, ConStr, "DATABASE=") - 1)
End If
If InStr(1, tdf.Connect, "TABLE=") > 0 Then
Sonrasi = Left(ConStr, InStr(1, ConStr, "TABLE=") - 1)
End If
tdf.Connect = Oncesi & "DATABASE=" & CurrentProject.Path & ";" & Sonrasi
Err = 0
On Error Resume Next
tdf.RefreshLink ' Relink the table.
If Err <> 0 Then
MsgBox "Bir hata oluştu"
End If
End If
Next tdf
End Function
access dosyasının bulunduğu klasör olarak değiştiriyor.