473,385 Members | 1,384 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How can VB6 alter the NAME of an EXISTING FIELD in ACCESS 2002???

I'm sorry if this one has been asked and answered a million times:

Is it possible to have a VB6 app alter the name of an *existing* field
in Access 2002 database? To be clear, I'm not talking about adding a
new field to the Access database. I want to change the name of an
*existing* field using a VB6 app.

What type of VB6 code would you use to do this? And please, if your
suggestion involves using Project References other than "Microsoft
Access 10.0 Object Library" and "Microsoft ActiveX Data Objects 2.7
Library", please specify which References I would need to add to the
Project to accommodate your suggestion.

I really appreciate your help.
Sep 16 '06 #1
2 3328
Alan Mailer wrote:
I'm sorry if this one has been asked and answered a million times:

Is it possible to have a VB6 app alter the name of an *existing* field
in Access 2002 database? To be clear, I'm not talking about adding a
new field to the Access database. I want to change the name of an
*existing* field using a VB6 app.

What type of VB6 code would you use to do this? And please, if your
suggestion involves using Project References other than "Microsoft
Access 10.0 Object Library" and "Microsoft ActiveX Data Objects 2.7
Library", please specify which References I would need to add to the
Project to accommodate your suggestion.

I really appreciate your help.
This one-liner seems to work from within Access. I'm not sure how to
adapt it to an external app, but it might be as easy as pre-pending the
database's object reference?

DBEngine(0)(0).TableDefs("MyTable").Fields("OldNam e").Name = "NewName"

--
Smartin
Sep 16 '06 #2
Using ADO you can

loCon.Execute "ALTER TABLE Table2 ADD COLUMN [Val1] varchar(50)"
loCon.Connection.Execute "UPDATE Table2 SET [Val1] = [Value]"
loCon.Connection.Execute "ALTER TABLE Table2 DROP COLUMN [Value]"

Where loCon is you connection object.

Alternatively create a reference to ADOX and then use that to create the
column instead of line 1 above (best done if this is going to be generic as
you can then replicate the attributes of the source field to the target
field).

--

Terry Kreft
"Alan Mailer" <cl**********@earthlink.netwrote in message
news:v3********************************@4ax.com...
I'm sorry if this one has been asked and answered a million times:

Is it possible to have a VB6 app alter the name of an *existing* field
in Access 2002 database? To be clear, I'm not talking about adding a
new field to the Access database. I want to change the name of an
*existing* field using a VB6 app.

What type of VB6 code would you use to do this? And please, if your
suggestion involves using Project References other than "Microsoft
Access 10.0 Object Library" and "Microsoft ActiveX Data Objects 2.7
Library", please specify which References I would need to add to the
Project to accommodate your suggestion.

I really appreciate your help.

Sep 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dylan Nicholson | last post by:
Seems that Oracle 9.2 (using MS ODBC driver) requires extra parentheses when adding multiple columns to a table: ALTER TABLE MyTable ADD (MyColumn1 VARCHAR(255), MyColumn2 VARCHAR(255)) vs ...
2
by: me | last post by:
I would like to add an Identity to an existing column in a table using a stored procedure then add records to the table and then remove the identity after the records have been added or something...
1
by: Euler Almeida via SQLMonster.com | last post by:
Hi people, I?m trying to alter a integer field to a decimal(12,4) field in MSACCESS 2K. Example: table : item_nota_fiscal_forn_setor_publico field : qtd_mercadoria integer NOT NULL...
2
by: HjKlOp | last post by:
Can I set fields lenghts of an existing database with "ALTER TABLE" command without lost data ?
1
by: jdph40 | last post by:
I have a table with fields EmpID (PK), EmployeeNumber, DateTaken, and YearTaken to track the dates an employee takes for vacation. I need a way to distinguish between years because the data will...
5
by: minjie | last post by:
Is it possible to run a simple script to alter a table column in Access database from an interger to a double? I have been writing C++ programs every time we need to upgrade (modify) the Access...
9
by: Alan Mailer | last post by:
Ok, my Access 2002 language writing skills are VERY rusty,. I would know how to do what I need using SQL Server's "Coalesce' function, but I don't have that available to me in the Access 2002...
3
by: sparks | last post by:
several months ago I was trying to set the field size of text fields in a table and Lyle Fairfield was nice enought to post a way using alter column. it was surprising since it was ALTER COLUMN...
2
by: rcamarda | last post by:
Hello, I need to alter fields in all my tables of a given database, and I would to do this via a t-sql script. Example, I want to change all fields called SESSION_ID to char(6). The field is...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.