Change FieldName

O

ooxx

Hello,

After a practice of doing traansfer database, I need to change the
FieldName. Ah, I can change the fieldName, if the transfertext, but what if
the transferdatabase of DBASE type. Can we change the FieldNames as
transfertext type?

If yes , please let me some information of how to do.

Thanks ,
 
F

fredg

Hello,

After a practice of doing traansfer database, I need to change the
FieldName. Ah, I can change the fieldName, if the transfertext, but what if
the transferdatabase of DBASE type. Can we change the FieldNames as
transfertext type?

If yes , please let me some information of how to do.

Thanks ,

Do you know in advance what the existing name of the field is?
Do you know in advance, what the new name should be?
After the import is completed you can run this procedure:

Public Sub ChangeFieldName()
Dim tbf As TableDef
Dim fld As Field
Dim db As DAO.Database
Set db = CurrentDb
Set tbf = db("ImportedTableName")
Set fld = tbf("ExistingFieldName")
fld.Name = "NewFieldName"
db.Close
Set db = Nothing
End Sub

If you do not know in advance what the existing Table and/or Field
names will be, you can use an input box to ask for the name instead of
hard coding it.

.....
Dim strTable as String
Dim strField as String
strTable = InputBox("Enter Table Name")
strField = InputBox("Enter the Field Name")
....etc...
Set tbf = db(strTable)
Set fld = tbf(strFieldName)
fld.Name = "NewFieldName"
....etc...
 
O

ooxx

Hello,

That's what I need, but I have something. I need not to know the old
FieldNames. I need to change them without knowing the old Fieldnames.
Whatever the the old FieldNames, just let them be. I think, unless you could
show the old Fieldnames up, otherwise you woudn't.

Thanks,
 
O

ooxx

Hi,

I just don't know the possible ways. Could New Fieldnames replace the old
without knowing the old Fieldnames?

Thanks,
 

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