|
Question : Setting a Column's Required Property to False using VBA
|
|
I have the following code to append new columns to a table. The Required property is defaulting to Yes which is causing problems when I run append queries. How can I modify this property in code?
Dim strSQL As String Dim cat As ADOX.catalog Dim cnn As New ADODB.Connection Dim tbl As ADOX.Table Dim col As ADOX.Column
Set cat = New ADOX.catalog Set cnn = CurrentProject.Connection Set cat.ActiveConnection = cnn
Set tbl = New ADOX.Table
DoCmd.OpenQuery "qryCreateTblChartAll"
Set tbl = cat.tables("tblChartAll")
Set col = New ADOX.Column col.Name = "Pd_Clm_Num" col.Type = adVarWChar tbl.columns.Append col
Set col = New ADOX.Column col.Name = "Pd_Clm_Amt" col.Type = adCurrency tbl.columns.Append col
Set col = New ADOX.Column col.Name = "Dnd_Clm_Num" col.Type = adVarWChar tbl.columns.Append col
Set col = New ADOX.Column col.Name = "Dnd_Clm_Amt" col.Type = adCurrency tbl.columns.Append col
|
|
Answer : Setting a Column's Required Property to False using VBA
|
|
col.Attributes=adColNullable
note the literal value for adColNullable = 2
|
|
|