how to set field properties in VBA

overclockgirl

New member
Local time
Today, 15:43
Joined
Jun 6, 2007
Messages
5
Hi,
I am creating (successfully :D ) lots of tables with VBA.
I need to be able to set the property called "Required" to False or No.
Is there a command to do this?
thanks
 
Hi,
I am creating (successfully :D ) lots of tables with VBA.
I need to be able to set the property called "Required" to False or No.
Is there a command to do this?
thanks

Simplest way I can think of in Access would be this.

Code:
CurrentDb.TableDefs("YourTable").Fields("FieldName").Required = False
 
that does look simple, but I'm not actually using any "TableDef" commands...and all of my tables and fields are variables stored in arrays.
Like I said, I am making LOTS of tables. And I need each field in each table to be set to Required = NO.
Here is some of my code:

Dim tbl As New ADOX.Table
Set tbl = New ADOX.Table
With tbl
tbl.name = tblName
With .Columns
For i = 1 To f - 1
AmpLine(i) = spaceReplace(AmpLine(i))
.Append AmpLine(i), adLongVarWChar
Next
.Append "R_ID", adInteger
.Append "INDEX", adInteger
With !RADAR_ID
Set .ParentCatalog = cat
.Properties("AutoIncrement") = False

End With
With !Index
Set .ParentCatalog = cat
.Properties("AutoIncrement") = True
End With
End With
End With
cat.Tables.Append tbl
Set cat = Nothing
 
that does look simple, but I'm not actually using any "TableDef" commands...and all of my tables and fields are variables stored in arrays.
Like I said, I am making LOTS of tables. And I need each field in each table to be set to Required = NO.
Here is some of my code:

Dim tbl As New ADOX.Table
Set tbl = New ADOX.Table
With tbl
tbl.name = tblName
With .Columns
For i = 1 To f - 1
AmpLine(i) = spaceReplace(AmpLine(i))
.Append AmpLine(i), adLongVarWChar
Next
.Append "R_ID", adInteger
.Append "INDEX", adInteger
With !RADAR_ID
Set .ParentCatalog = cat
.Properties("AutoIncrement") = False

End With
With !Index
Set .ParentCatalog = cat
.Properties("AutoIncrement") = True
End With
End With
End With
cat.Tables.Append tbl
Set cat = Nothing

Ok try this for ADOX

Code:
tbl.ParentCatalog = cat
tbl.Columns("YourColumnName").Properties("Nullable") = True
 
thanks

Thank you so much! That works perfectly!
I'm not a "programmer" & I would have never tried "nullable"
 

Users who are viewing this thread

Back
Top Bottom