Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add column to table 1

Status
Not open for further replies.

tomvdduin

Programmer
Sep 29, 2002
155
NL
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
 
.Name [highlight]=[/highlight] in_columnName

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Wow, how stupid can I be... Maybe it's because it is 11pm in the netherlands?
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top