PC Review


Reply
Thread Tools Rate Thread

Auto-rename table field with VBA/ADO?

 
 
sbcglobal
Guest
Posts: n/a
 
      8th Feb 2005
I have a table, 'Customer', which I want to use VBA/ADO to auto rename all
the fields. for example, to rename fields 1 to 'customer name', field to
'customer address' ,etc.

in Access, there's query 'Alter table, Alber column' but it only do for
changing column property, say set column as text/number, etc. I don't know
there's way to use SQL to rename a field in table.

I use Access2003 ANSI92. Thanks for any hints!

Warren
**************************************************
The Spoon Does Not Exist.


 
Reply With Quote
 
 
 
 
Naresh Nichani MVP
Guest
Posts: n/a
 
      8th Feb 2005
Hi:

One way to do this --

1. Use Alter Table SQL to add a new column
2. Use Update Query to copy data from old col to new column
3. Use Alter Table to delete old column.

However new column will not get any of the Indexes and Foeign Keys of the
old column.

Regards,

Naresh Nichani
Microsoft Access MVP

"sbcglobal" <(E-Mail Removed)> wrote in message
news:q2YNd.39300$(E-Mail Removed)...
> I have a table, 'Customer', which I want to use VBA/ADO to auto rename all
> the fields. for example, to rename fields 1 to 'customer name', field to
> 'customer address' ,etc.
>
> in Access, there's query 'Alter table, Alber column' but it only do for
> changing column property, say set column as text/number, etc. I don't know
> there's way to use SQL to rename a field in table.
>
> I use Access2003 ANSI92. Thanks for any hints!
>
> Warren
> **************************************************
> The Spoon Does Not Exist.
>
>



 
Reply With Quote
 
sbcglobal
Guest
Posts: n/a
 
      8th Feb 2005
thanks, Nichani. the thing is I have too many fields to rename (about 40). I
hate to rename it in Excel and then import. I want to use some code to
import the table and rename fields at same time. or import table first, then
rename all fields at one time.

Basically I have 2 'group' of field names, one set for myself, another for
other users. so I want to 'switch' between these sets...ideas?

rgds,


"Naresh Nichani MVP" <nareshnichani@HOT MAIL> wrote in message
news:(E-Mail Removed)...
> Hi:
>
> One way to do this --
>
> 1. Use Alter Table SQL to add a new column
> 2. Use Update Query to copy data from old col to new column
> 3. Use Alter Table to delete old column.
>
> However new column will not get any of the Indexes and Foeign Keys of the
> old column.
>
> Regards,
>
> Naresh Nichani
> Microsoft Access MVP
>
> "sbcglobal" <(E-Mail Removed)> wrote in message
> news:q2YNd.39300$(E-Mail Removed)...
>> I have a table, 'Customer', which I want to use VBA/ADO to auto rename
>> all
>> the fields. for example, to rename fields 1 to 'customer name', field to
>> 'customer address' ,etc.
>>
>> in Access, there's query 'Alter table, Alber column' but it only do for
>> changing column property, say set column as text/number, etc. I don't
>> know
>> there's way to use SQL to rename a field in table.
>>
>> I use Access2003 ANSI92. Thanks for any hints!
>>
>> Warren
>> **************************************************
>> The Spoon Does Not Exist.
>>
>>

>
>



 
Reply With Quote
 
=?Utf-8?B?S0pHaW5OQw==?=
Guest
Posts: n/a
 
      8th Feb 2005
I'd use an Import Specification, but that might not meet your needs either.

"sbcglobal" wrote:

> I have a table, 'Customer', which I want to use VBA/ADO to auto rename all
> the fields. for example, to rename fields 1 to 'customer name', field to
> 'customer address' ,etc.
>
> in Access, there's query 'Alter table, Alber column' but it only do for
> changing column property, say set column as text/number, etc. I don't know
> there's way to use SQL to rename a field in table.
>
> I use Access2003 ANSI92. Thanks for any hints!
>
> Warren
> **************************************************
> The Spoon Does Not Exist.
>
>
>

 
Reply With Quote
 
John Nurick
Guest
Posts: n/a
 
      8th Feb 2005
On Tue, 08 Feb 2005 06:37:05 GMT, "sbcglobal" <(E-Mail Removed)>
wrote:

>Basically I have 2 'group' of field names, one set for myself, another for
>other users. so I want to 'switch' between these sets...ideas?


Changing the structure (including field names) of your database as a
routine operational procedure is never a good idea. Instead, use your
own names in the table, and have other users access the table via
queries that map their preferred names to the underlying ones, e.g.

SELECT ID, Fish AS Poisson, Meat AS Viande FROM MyTable;
SELECT ID, Fish AS Fisch, Meat AS Fleisch FROM MyTable;

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rename a field in a table Andrew Microsoft Access VBA Modules 4 15th Apr 2008 02:35 AM
how to rename a table using field name ghost Microsoft Access 1 13th Mar 2008 04:06 PM
SQL Syntax to rename a field in a Table ScardyBob Microsoft Access 11 13th Feb 2007 07:00 PM
automatially rename table field name =?Utf-8?B?VmluY2U=?= Microsoft Access 0 13th Oct 2006 04:04 PM
Rename field name in table Tom Microsoft Access Form Coding 2 10th Dec 2005 03:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:05 AM.