Bonjour j'ai un probleme avec mon code qui ne veut pas tourner correctement...Il me dit qu'il y a un probleme...Je veux en gros a partir d'un fichier excel changer le nom de certain champs de plusieurs table access.

Voici mon code






Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Function RenommerChamp(NomTable As String, Ancien As String, Nouveau As String) As Boolean
On Error GoTo err:
Dim MCat As New ADOX.Catalog
Dim MTable As ADOX.Table
Dim MField As ADOX.Column
Set MCat.ActiveConnection = CurrentProject.Connection
Set MTable = MCat.Tables(NomTable)
Set MField = MTable.Columns(Ancien)
MField.Name = Nouveau
RenommerChamp = True
err:
Set MCat = Nothing
Set MTable = Nothing
Set MField = Nothing
End Function
 
 
 
Sub essai()
 
Dim MaBase As String
MaBase = "E:\Projet GDP\Projet Marie Alice\base.accdb"
 
Set AccessCn = New ADODB.Connection
AccessCn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                "Data Source=" & MaBase
 
 
MsgBox RenommerChamp("AC#CA", "Date", "Dateseance")
 
 
 
End Sub
Merci!