please always write the code inside the code tags .it is much readable.
Code:
Option Explicit
'Components : Microsoft FlexGrid Control 6.0 (FLEX)
'References 1: Microsoft Activex Data Objects 2.8 library (ADO)
'References 2: Microsoft Ado Ext. 2.8 for DDL and Security (ADOX)
Private Sub Form_Load()
Dim totFIELDS!, dbPTH$, f%, CAT As ADOX.Catalog, tADOX As ADOX.Table
Dim dbCON As New ADODB.Connection, cmdOBJ As New ADODB.Command, tOBJ As New ADODB.Recordset
totFIELDS = 254 'fields defined
dbPTH$ = "c:\database01.mdb": Kill dbPTH$ 'Define n del DataBase
'Create DataBase
Set CAT = New ADOX.Catalog
CAT.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPTH$ & ";Mode=Read|Write"
CAT.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPTH$ & ";Mode=Read|Write"
Set tADOX = New ADOX.Table
tADOX.Name = "OBJ" 'DEFININDO A TABELA (OBJ):
Set tADOX.ParentCatalog = CAT
For f% = 0 To totFIELDS! 'totFIELDS > 254 gives error [Too many fields defined]
With tADOX.Columns
.Append "REG" & f%, adVarWChar, 52 'Tipo Text
.Item(f%).Attributes = adColFixed + adPropRequired
End With
Next f
'totFIELDS > 254 gives error [Too many fields defined] in the line below
CAT.Tables.Append tADOX
Set CAT = Nothing: Set tADOX = Nothing
'Open DataBase
dbCON.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPTH$ & ";Mode=Read|Write"
dbCON.CursorLocation = adUseClient
dbCON.Open
With cmdOBJ
.ActiveConnection = dbCON
.CommandText = "SELECT * FROM OBJ" 'txSQL$
.CommandType = adCmdText
End With
With tOBJ 'Cria a Tabela OBJ
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open cmdOBJ
End With
End Sub