Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Alan Mailer
Guest
 
Posts: n/a
#1: Sep 16 '06
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.
Smartin
Guest
 
Posts: n/a
#2: Sep 16 '06

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


Alan Mailer wrote:
Quote:
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
Terry Kreft
Guest
 
Posts: n/a
#3: Sep 18 '06

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


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" <clarityassoc@earthlink.netwrote in message
news:v36og2to38jeulki53clsdukd3pckpprv9@4ax.com...
Quote:
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.

Closed Thread