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

Renaming MSAccess Fields

Status
Not open for further replies.

AtomicChip

Programmer
May 15, 2001
622
CA
Here's the problem:

I need to be able to update field names depending on user entry.

Example:

For Each Field in Recordset
If Recordset.Field.Name = text1.text Then
Recordset.Field.Name = text2.text
next
next Field

Problem is, of course, that the name property of a field is read-only. The other option is to create a new field, and update the information in the new field from the old field, and then delete the old field. I tried doing that, but every time I tried running it, I got a "Cannot create in context" error. Any ideas? Thanks in advance.
-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Well, it is not all that hard. But it is hazzardous to your health unless you are the owner and only user of the database and do not have any queries/forms/reports/modules (which reference the tables) ...

If you are that super admin owner and sole operator, then it would be easier to just do it all in design mode within the db?

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
This is a multi-user system (possibly going for commercial release - Doing it for my college practicum). There is nothing else within Access that reference these fields statically. Everything is done within VB (Reports, Queries, etc.). Everything there was thought out. All I need help with is the syntax of the statement itself (to either rename the field, or create a new one and delete the old one). Thanks.
-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
I wouldn't dream of suggesting to someone at college that altering field names in a multi-user database was other than a sound idea. So I won't.

Look up Alter Table. That will show you how to add and delete columns. Peter Meachem
peter@accuflight.com
 
What you need to do is change the name of the field in the database ..... Name:[Field] for example to change the name of the "Customers" field to "Preferred Customers" do the following in the query Preferred Customers:[Customers]

hope this is helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top