Is it possible to change a table field name's description using ADO code?
Example: Table name = myTable
FieldName=Apple, DataType=Text and Description=None
I would like the Description associated with the FieldName Apple to change from None to Green.
Thanks for taking a look,
John
ADO Code To Change A Table FieldName's Description
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
ADO Code To Change A Table FieldName's Description
Regards,
John
John
-
- Administrator
- Posts: 78524
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: ADO Code To Change A Table FieldName's Description
You need to set a reference to the "Microsoft ADO Ext. 2.8 for DDL and Security" library (for .mdb) or to the "Microsoft ADO Ext. 6.0 for DDL and Security" library (for .accdb).
I assume that you already have an ADODB connection to the database, say in a variable conn.
You can then use code like this:
I assume that you already have an ADODB connection to the database, say in a variable conn.
You can then use code like this:
Code: Select all
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim col As ADOX.Column
' code to set/open conn
...
' Make a catalog for the database.
Set cat = New ADOX.Catalog
Set cat.ActiveConnection = conn
' Get the table.
Set tbl = cat.Tables("myTable")
' Get the column.
Set col = tbl.Columns("Apple")
' Set the Description property.
col.Properties("Description") = "Green"
Best wishes,
Hans
Hans
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Re: ADO Code To Change A Table FieldName's Description
Hans,
I was able to change the description.
I learned something new today about ADOX.
Thank you,
John
I was able to change the description.
I learned something new today about ADOX.
Thank you,
John
Regards,
John
John