Rename a field by code.

N

NKN

Hi all,

Does anybody know how can I rename a field but not using the interface
provided by Office but by code. Is there any instruction I can execute?

I'm programing in VB and the batabase is Access from Office XP.

Thanks in advance,

Naiara.
 
N

Nikos Yannacopoulos

Naiara,

The syntax is:

CurrentDb.TableDefs("TableName").Fields("OldFieldName").Name =
"NewFieldName"

Note: if the table is opened or in use by another process (form, query etc)
the method will fail.

HTH,
Nikos
 
N

NKN

It works!! Thanks Nikos.

Naiara.

Nikos Yannacopoulos said:
Naiara,

The syntax is:

CurrentDb.TableDefs("TableName").Fields("OldFieldName").Name =
"NewFieldName"

Note: if the table is opened or in use by another process (form, query etc)
the method will fail.

HTH,
Nikos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top