G
Gary D.
Not sure if this is the correct group for this question.
I am trying to create a table in VBA and create and define the table's
fields.
I can create the tabledef and the fields okay, but I want to add
certain properties to certain fields.
This is what I have so far...
Dim ldbCreateCtrls As Database, tdfCreateCtrls As TableDef
Dim fdlCreateCtrls As Field, prpCreateCtrls As Property
Set tdfCreateCtrls = ldbCreateCtrls.CreateTableDef("tbl_APP_CONTROLS")
Set fdlCreateCtrls = tdfCreateCtrls.CreateField("CtrlDBName", dbText,
30)
tdfCreateCtrls.Fields.Append fdlCreateCtrls
tdfCreateCtrls.Fields("CtrlDBName").DefaultValue = "database name"
tdfCreateCtrls.Fields("CtrlDBName").Required = True
tdfCreateCtrls.Fields("CtrlDBName").AllowZeroLength = False
ldbCreateCtrls.TableDefs.Append tdfCreateCtrls
and these are all effective.
However, I wish to edit a field's Caption, Format and Description.
But despite trying all manner of different code, I cannot get the
correct technique.
I've tried
Set prpCreateCtrls =
tdfCreateCtrls.Fields("CtrlDBName").CreateProperty("Caption", dbText,
"Database")
which works but then fails on
tdfCreateCtrls.Fields.Append prpCreateCtrls
which I understand, because Caption is already in the collection.
So what is the correct technique?
I am trying to create a table in VBA and create and define the table's
fields.
I can create the tabledef and the fields okay, but I want to add
certain properties to certain fields.
This is what I have so far...
Dim ldbCreateCtrls As Database, tdfCreateCtrls As TableDef
Dim fdlCreateCtrls As Field, prpCreateCtrls As Property
Set tdfCreateCtrls = ldbCreateCtrls.CreateTableDef("tbl_APP_CONTROLS")
Set fdlCreateCtrls = tdfCreateCtrls.CreateField("CtrlDBName", dbText,
30)
tdfCreateCtrls.Fields.Append fdlCreateCtrls
tdfCreateCtrls.Fields("CtrlDBName").DefaultValue = "database name"
tdfCreateCtrls.Fields("CtrlDBName").Required = True
tdfCreateCtrls.Fields("CtrlDBName").AllowZeroLength = False
ldbCreateCtrls.TableDefs.Append tdfCreateCtrls
and these are all effective.
However, I wish to edit a field's Caption, Format and Description.
But despite trying all manner of different code, I cannot get the
correct technique.
I've tried
Set prpCreateCtrls =
tdfCreateCtrls.Fields("CtrlDBName").CreateProperty("Caption", dbText,
"Database")
which works but then fails on
tdfCreateCtrls.Fields.Append prpCreateCtrls
which I understand, because Caption is already in the collection.
So what is the correct technique?