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
| Function verif_attache_table(ByVal attache As String)
On Error GoTo vat_error
Dim Mabd As Database
Dim i As Integer, comptefic As Integer
Dim matable As TableDef
Dim monjeu As Recordset
Dim nb_table As Long
Dim taille_gauge As Long
Set Mabd = CurrentDb
DoCmd.Hourglass True
comptefic = 1
nb_table = Mabd.TableDefs.count - 1
taille_gauge = Forms!m_vérif_attache!gauge.Width
Forms!m_vérif_attache!gauge.Width = 0
Forms!m_vérif_attache!gauge.Visible = True
For i = 0 To Mabd.TableDefs.count - 1
Set matable = Mabd.TableDefs(i)
If matable.Attributes = dbAttachedTable Then
DoCmd.Echo True, "Traitement de " & matable.name & "......"
matable.Connect = "ODBC;DATABASE=" & attache
Err = 0
matable.RefreshLink
comptefic = comptefic + 1
If Err <> 0 Then
MsgBox "ERREUR N° " & Err
End If
End If
Forms!m_vérif_attache!gauge.Width = taille_gauge / nb_table * i
Forms!m_vérif_attache!gauge.Caption = Int((1 / nb_table) * i * 100) & "%"
Forms!m_vérif_attache.Repaint
Next i
Forms!m_vérif_attache!gauge.Caption = "100%"
Set monjeu = Mabd.OpenRecordset("config")
If monjeu.RecordCount > 0 Then
monjeu.MoveFirst
monjeu.Edit
monjeu!BDSource = Forms!m_vérif_attache!attache_table
monjeu.Update
End If
monjeu.Close
Set monjeu = Nothing
DoCmd.Hourglass False
MsgBox "Mise à jour des attaches correcte. Opération terminée", vbInformation
vat_exit:
Forms!m_vérif_attache!connexion = ""
DoCmd.Hourglass False
DoCmd.Close acForm, "M_Vérif_attache"
Exit Function
vat_error:
Resume Next
End Function |
Partager