Hi everyone,
I am trying to change the field names for a table that is being
exported via Excel. Its a spreadsheet that our National Office sends
us but even after promise after promise they keep changing the field
names which makes it nearly impossible to run any pre-generated
queries etc.
The solution really is to get someone to check the field names before
importing the spreadsheet but I want to do it in code. I have written
a utility to display the table fields on a form and using a series of
combo boxes allows the users to select the correct names for the
fields. On a button on the form I detect the fields that are going to
change and send the values to two global variables (oldList and
newList) which are two lists telling what the old field name is and
one telling what to change it to. I then close the form (because I
don't want any objects referencing the originating table to be open)
and open a new dummy form with the following code on the onload event
handler:
Set td = db.TableDefs("geocodeInput")
For i = 0 To UBound(oldListArr)
td.Fields(oldListArr(i)).NAME = newListArr(i)
Next i
Set td = Nothing
db.close
I get an error that says the table is already being used by another
user or process but I have checked to make sure all database objects
that use the table are closed.
Any ideas?