Bonjour le Forum,

Je souhaite, en VBA, lors d'une création de table, pouvoir définir un champ NumAuto avec un format particulier.
Vu sur le forum :
Nom : 1.png
Affichages : 208
Taille : 5,5 Ko
Cette opération est manuelle.
J'aimerai faire tout pareil dans le code suivant :
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
 
Function créat_Table()
Dim tb As DAO.TableDef, fi As DAO.Field, ix As Index
Set tb = CurrentDb.CreateTableDef("TKRPCF01")
    With tb
        Set ix = .CreateIndex("ID")
        ix.Fields.Append ix.CreateField("ID", dbLong)
        ix.Primary = True
 
        .Fields.Append .CreateField("ID", dbLong)
        .Fields("ID").Attributes = 17
 
        .Fields.Append .CreateField("Champ1", dbText, 2)
        .Fields.Append .CreateField("Champ2", dbText, 7)
        .Fields.Append .CreateField("Champ3", dbText, 9)
        .Fields.Append .CreateField("Champ4", dbText, 131)
        .Fields.Append .CreateField("Champ5", dbText, 1)
 
        .Indexes.Append ix
    End With
 CurrentDb.TableDefs.Append tb
End Function
Merci de vos bons soins.