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
| Function action(catalogueName As String)
Dim bdd As DAO.Database
Dim tdfNew As DAO.TableDef
Dim tdfLoop As DAO.TableDef
Dim fLoop As DAO.Field
Dim sql As String
Dim count As Integer
Set bdd = Application.CurrentDb
count = 0
If TableExists(catalogueName) Then
sql = "DELETE * FROM " & catalogueName
bdd.Execute sql
Else
sql = "CREATE TABLE " & catalogueName & _
" ( tableName Text(64), fieldName Text(64), typeColumn Text(64), dateCreated Date, position integer, required text(10) )"
bdd.Execute sql
sql = "ALTER TABLE " & catalogueName & " ADD CONSTRAINT I_Tablefield PRIMARY KEY ( tableName, fieldName )"
bdd.Execute sql
End If
With bdd
For Each tdfLoop In .TableDefs
If tdfLoop.Name = catalogueName Then
'Msgbox "skip " & tdfLoop.Name
'help me!
'if tdfLoop.Properties
'MsgBox "skip " & tdfLoop.Name
Else
For Each fLoop In tdfLoop.Fields
sql = "insert into " & catalogueName & " ( tableName, fieldName, typeColumn, DateCreated, position, required ) " & _
" VALUES ( ' " & fLoop.SourceTable _
& "','" & fLoop.Name _
& "','" & fLoop.Type & " (" & fLoop.Size & ")" _
& "','" & tdfLoop.DateCreated _
& "','" & fLoop.OrdinalPosition _
& "','" & fLoop.Required _
& "')"
count = count + 1
.Execute sql
Next fLoop
End If
Next tdfLoop
End With
action = count
End Function |
Partager