1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| Option Compare Database
Function RafraichirLiens()
'Déclaration des variables.
Dim dbs As Database
Dim tdf As TableDef
Dim ntable As String
Dim loctable As String
Dim listfic As String
Dim ancConnect As String
Dim fd As FileDialog
'Section pour récupérer le chemin avec boîte de dialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
With fd
fd.ButtonName = "Valide"
fd.Title = "Récupération Chemin des tables"
fd.Filters.Add "Base ACCESS", "*.mdb", 1
fd.FilterIndex = 1
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
listfic = vrtSelectedItem
Next vrtSelectedItem
End If
End With
If listfic = "" Then
MsgBox "commande annulée par utilisateur"
Exit Function
End If
Set fd = Nothing
'Section mise à jour des tables.
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Len(tdf.Connect) > 0 Then
ntable = tdf.Name
ancConnect = tdf.Connect
loctable = ";DATABASE=" & listfic
tdf.Connect = loctable
Err = 0
On Error Resume Next
tdf.RefreshLink
If Err <> 0 Then
RefreshLinks = False
MsgBox (ntable & "n'a pas été trouvé à " & loctable)
Else
End If
End If
Next tdf
MsgBox ("mise à jour terminée")
DoCmd.OpenForm "Formulaire1" 'Mettre le nom du Form d'ouverture
RefreshLinks = True
End Function |
Partager