Hi all!
I want to add a column to a table and I wrote this piece of code to do that:
Public Sub mc_add_column_table(in_tableName As String, in_columnName As String, in_columnType As Integer, Optional in_columnPrecision As Long)
Dim cnn As New ADODB.Connection
Dim cat As New ADOX.Catalog
Dim column As New ADOX.column
Set cnn = CurrentProject.Connection
Set cat.ActiveConnection = cnn
With column
.Name in_columnName
.Type in_columnType
.Precision in_columnPrecision
End With
cat.Tables(in_tableName).Columns.Append column
Set cat = Nothing
End Sub
however, when I call this sub with:
mc_add_column_table "Xtbl_TEST","test",adVarWChar, execution breaks at the .Name line, saying something like 'improper user of a property' (translated from dutch)
What's wrong with this piece of code?
Thanks for helping!
Tom
I want to add a column to a table and I wrote this piece of code to do that:
Public Sub mc_add_column_table(in_tableName As String, in_columnName As String, in_columnType As Integer, Optional in_columnPrecision As Long)
Dim cnn As New ADODB.Connection
Dim cat As New ADOX.Catalog
Dim column As New ADOX.column
Set cnn = CurrentProject.Connection
Set cat.ActiveConnection = cnn
With column
.Name in_columnName
.Type in_columnType
.Precision in_columnPrecision
End With
cat.Tables(in_tableName).Columns.Append column
Set cat = Nothing
End Sub
however, when I call this sub with:
mc_add_column_table "Xtbl_TEST","test",adVarWChar, execution breaks at the .Name line, saying something like 'improper user of a property' (translated from dutch)
What's wrong with this piece of code?
Thanks for helping!
Tom