There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
audio avg avg 8 bios boot browser bsod computer cpu crash css dell desktop driver dvd email error excel explorer firefox firefox 3 freeze game graphics hard drive hardware help please hijackthis hjt install internet internet explorer itunes javascript lan laptop malware missing monitor msn network networking openoffice outlook outlook 2003 outlook express php popups problem problems router seo slow sound sp3 spyware startup trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless word
Archive: Business Applications
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Business Applications > Archive: Business Applications >
{Solved} Access: Renaming a tables field names with code.


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Talismanic's Avatar
Senior Member with 412 posts.
 
Join Date: May 2000
Location: Three Rivers, MI
27-Apr-2001, 02:05 PM #1
Is it possible to rename table field names with code. I have a spreadsheet that is beeing imported from Excel and I would like to set the headers once the table is imported into Access.

I know that I can have Access assign the first row as field names but that approach will not work in this case. Any ideas?
Talismanic's Avatar
Senior Member with 412 posts.
 
Join Date: May 2000
Location: Three Rivers, MI
27-Apr-2001, 03:35 PM #2
I did it with a Make Table Query by modifying the SQL like this:

SELECT Jobs.F1 AS JobNumber, Jobs.F2 AS JobName, Jobs.F3 AS Travel, Jobs.F4 AS PW INTO JobNumbers
FROM Jobs;

Thanks anyways!
EAFiedler's Avatar
Moderator with 9,269 posts.
 
Join Date: Apr 2000
29-Apr-2001, 12:25 AM #3
Keep up the good work Talismanic!

I'll mark this one as Solved
YSB's Avatar
YSB YSB is offline
Senior Member with 781 posts.
 
Join Date: Mar 1999
Location: New York City
04-May-2001, 02:04 AM #4
I believe there is another way to do it but I have to try it out first to make sure I don't give you incorrect code. I'm just bringing this thread back to the top so I don't forget to try it when I'm at my other computer.
YSB's Avatar
YSB YSB is offline
Senior Member with 781 posts.
 
Join Date: Mar 1999
Location: New York City
06-May-2001, 05:23 AM #5
Lightbulb Got it!
I tried it out and it works. You can rename a tables fields in code like this:

CurrentDb.Tabledefs("NameOfTable").Fields("OldName").Name = "NewName"
Talismanic's Avatar
Senior Member with 412 posts.
 
Join Date: May 2000
Location: Three Rivers, MI
08-May-2001, 08:43 AM #6
Very cool, YSB. Doing it with code allows me more flexibility.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:21 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.