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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Method to change column names

Status
Not open for further replies.

chelandrew

IS-IT--Management
Oct 8, 2001
25
0
0
US
Is there a method that can be called that can change column names in access2000? Problem relates to the length of some column names that cause big problems via ODBC.
 
Here is the code to add a table and columns. I haven't modified table but it should be possible.
'-- set reference to ADOX library
'- Microsoft ADO Ext. 2.6 for DDL and Security
'-- Microsoft ActiveX data objects 2.6 library also needed for ADO

Dim cg As New Catalog
Dim tb As New ADOX.Table
Dim cn As ADODB.Connection
Set cn = CurrentProject.Connection

tb.Name = "Test"
tb.Columns.Append "col1", adInteger
tb.Columns.Append "col2", adVarWChar, 50
cg.Tables.Append tb

You can check the reference to see if it allows change. After putting code in Access right click on Columns and pick definition. This allows you to look at available functions/properties. Check under Column, it has a name property. You may be able to update.
 
The generic SLQ "Alter Table ... " works. BUt I wouldn't advise it. It would be easier and safer to just alais the table names in the overall process. There may be code / forms / modules in the data base of other user's interface which reference the objects. Change the object names and you've broken all of these. Worst case, generate a query which references the tables - use the query names in the interface.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top