is there a way to drop an index on a column field in a table in Access 2010

I am importing tables and there are a lot of them.  Is there a way, with vba, to remove the index on certain columns?  I will have to be doing this process several times and I want to automate it.  Problem is when I try to remove a column, if there is an index on it, I cannot drop the column in code.
Sandra SmithRetiredAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pcelbaCommented:
Yes, you may use DROP INDEX command.

More info: https://msdn.microsoft.com/en-us/library/bb177897(v=office.12).aspx
0
Sandra SmithRetiredAuthor Commented:
I already did a search and what is confusing is they want a name of an index, but column indexes do not have names.  That is the issue I need, how to drop the index on a column, not a named index.  Please provide an example, not a link.
0
Rey Obrero (Capricorn1)Commented:
try this code

Dim db As DAO.Database, td As DAO.TableDef, fld As DAO.Field
Set db = CurrentDb
For Each fld In db.TableDefs("NameOFTable").Fields
    If fld.Name = "Field1" Then
        fld.Name = "Field2"
    End If
Next
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Rey Obrero (Capricorn1)Commented:
oops, sorry wrong thread..
0
Sandra SmithRetiredAuthor Commented:
OK, Ray,your suggestion answered another question!  So, please post it to that question as this one related to getting rid of an index, not changing the name of an existing column!  LOL!!  Please post to the other question and I will accept as your solution worked perfectly for what I wanted!
0
pcelbaCommented:
If you create the table in VBA and assign names to all indexes then you may drop such indexes. You may also enumerate all indexes and retrieve the index names. More ideas are in this code: https://msdn.microsoft.com/en-us/library/bb177466(v=office.12).aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sandra SmithRetiredAuthor Commented:
Ok, this did it and actually, is better than what I wanted.  If I can loop through all the indexes, it saves me having to do them one by one.  The prior developers put indexes on about half the columns of every table so this saves me a good deal of time.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.