Hi
If all you can do with ALTER TABLE....ALTER COLUMN is change the datatype/size then how do I change the name of a field?
I have several database files spread all over the state and some of the users (Darn users!) have changed a field from "Datum" to "MapDatum" and I need to change it back because it is causing problems with the front end.
I suspect that I'm going to have to determine if the field MapDatum exists and if it does, make a new column, copy all the data over and drop the old column.
Is there any way to just change the name in code? Otherwise it's probably going to be quicker (but nowhere near as elegant) to open each database, open the table in design view and change it there!
Jim
7 4974
Hi
If all you can do with ALTER TABLE....ALTER COLUMN is change the datatype/size then how do I change the name of a field?
I have several database files spread all over the state and some of the users (Darn users!) have changed a field from "Datum" to "MapDatum" and I need to change it back because it is causing problems with the front end.
I suspect that I'm going to have to determine if the field MapDatum exists and if it does, make a new column, copy all the data over and drop the old column.
Is there any way to just change the name in code? Otherwise it's probably going to be quicker (but nowhere near as elegant) to open each database, open the table in design view and change it there!
Jim
This will loop 'all' tables seeking the offending field and change it for the 'current' database Jim..... but I'm a little confused as to the 'all over the state' bit you speak about where is the table located obviously this code below does not target external databases in any logical sweep merely the current one? - Dim db As DAO.Database
-
Dim tbl As DAO.TableDef
-
Dim fld As DAO.Field
-
Set db = CurrentDb()
-
For Each tbl In db.TableDefs
-
For Each fld In tbl.Fields
-
If fld.Name = "MapDatum" Then fld.Name = "Datum"
-
Next
-
Next
-
Regards
Jim :)
This will loop 'all' tables seeking the offending field and change it for the 'current' database Jim..... but I'm a little confused as to the 'all over the state' bit you speak about where is the table located obviously this code below does not target external databases in any logical sweep merely the current one? - Dim db As DAO.Database
-
Dim tbl As DAO.TableDef
-
Dim fld As DAO.Field
-
Set db = CurrentDb()
-
For Each tbl In db.TableDefs
-
For Each fld In tbl.Fields
-
If fld.Name = "MapDatum" Then fld.Name = "Datum"
-
Next
-
Next
-
Regards
Jim :)
That will do nicely thanks Jim. "All over the state" means just that, on computers all over the state of Victoria, Australia. It's a front end/back end setup where the back ends are located on each and every users C:\ drive!
Please, don't look at me like that, I didn't design it.
The back ends do get sent in to the head office periodically and this is coming up soon so I'm writing a little fixer-upper code for the poor woman who administers this mess.
Thanks for the code, I was actually getting pretty close. I can cut down one of the loops because I know what table I'm going to look at.
Jim
That will do nicely thanks Jim. "All over the state" means just that, on computers all over the state of Victoria, Australia. It's a front end/back end setup where the back ends are located on each and every users C:\ drive!
Please, don't look at me like that, I didn't design it.
The back ends do get sent in to the head office periodically and this is coming up soon so I'm writing a little fixer-upper code for the poor woman who administers this mess.
Thanks for the code, I was actually getting pretty close. I can cut down one of the loops because I know what table I'm going to look at.
Jim
Fine..merely interested kinda knew you'd have no problem overall
Jim :)
Fine..merely interested kinda knew you'd have no problem overall
Jim :)
All installed, debugged and delivered. I get paid next Thursday and I hope it's the last I see of that application.
How come I never get the jobs where you get to design an application from scratch? You know, all the 1NF, 2NF, 3NF stuff I learned in uni?
Ah well...
Jim
All installed, debugged and delivered. I get paid next Thursday and I hope it's the last I see of that application.
How come I never get the jobs where you get to design an application from scratch? You know, all the 1NF, 2NF, 3NF stuff I learned in uni?
Ah well...
Jim
Hahaha yes seems a million miles away I guess
I get paid next Thursday and I hope it's the last I see of that application.
Can you say "Not a chance in the world!" JustJim?
I knew you could!
Linq ;0)>
Can you say "Not a chance in the world!" JustJim?
I knew you could!
Linq ;0)>
Not even one tiny little chance in all the world? Sheesh!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dave C. |
last post by:
Hello,
I have created the following trigger:
CREATE TRIGGER tr_UDFTest ON UserDefinedFields FOR INSERT, UPDATE
AS
DECLARE @foobar varchar(100)
SELECT @foobar= foobar FROM inserted
IF (...
|
by: ibm_97 |
last post by:
DB2 8.2 on AIX
Hi,
I'd like to change a column's name in a table which is part of
replication.
This column is identity column (generated always).
1. Since DB2 will drop and recreate the...
|
by: A Clark |
last post by:
I have a subform that displays a datasheet. There are a couple of
different queries that can be displayed in the datasheet. The queries
are available in a combo box on the main form. The problem...
|
by: Amber |
last post by:
There are times when you will need to highlight or otherwise modify
the contents of a particular DataGrid row-column value based upon the
value in the column. In this example we will select the...
|
by: Aaron Smith |
last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child
tables, I have a column that I added to the DataSet (Not in the
DataSource). This column does not need to be stored in the...
|
by: ymcj |
last post by:
Hi, I'm trying to change the column name - date to Sdate in all the tables in my database. As i have many to change so i tried to search all tables and have it change automatically rather than...
|
by: Greg Strong |
last post by:
Hello All,
Is it possible to change table field lookup properties in code?
I've been able to change other field properties in code, however so far
no luck with field lookup properties. What...
|
by: kjqua |
last post by:
Hi all,
I am newbie in c# and i have a question regarding DataGridView
I have a Table with 3 Columns
(0)IdLeggiSeriale <Is Primary key>
(1)ValoreSeriale <Is Integer>...
|
by: Czechtim |
last post by:
Hello, I have problem with databinding. I created small application using structure that I need to demonstrate problem.
I need to change content of label when changing content of property...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |