473,385 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

changing field names

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?
Nov 12 '05 #1
3 3009
On 16 Feb 2004 18:51:26 -0800, Michael wrote:
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?


Are any relationships defined using this field?
--
Mike Storr
www.veraccess.com
Nov 12 '05 #2
Thanks for your quick reply.
The table isn't involved in any relationships.

The problem seems to be stemming from the fact that I execute the code
from a form that has the source table as a recordsource even though I
have closed the form before running it. I solved the problem by passing
the user to a new form with a "click this button to complete" message on
it , where the code executes no problem.

This is really clunky though but seemingly necessary.

:)


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
If the execution of the new code comes from a form, then the form can't be
closed before that new code runs (unless the new code closes the form). For
instance if a button click event you do this

Docmd.Close .....
Set td = .....

Then the code must finish running before the form can actually destroy
itself. Even if you branch out to external sub or function from the button
event, execution must return to the form to be completed. You might try in
this external function, making the form invisible, changing it's
recordsource to something else (like "" to make it unbound), then perform
your actions on the TableDef. After changing the recordsource, the form
could be closed at any point.

Mike Storr
www.veraccess.com
"Michael West" <we****@hotmail.com> wrote in message
news:40*********************@news.frii.net...
Thanks for your quick reply.
The table isn't involved in any relationships.

The problem seems to be stemming from the fact that I execute the code
from a form that has the source table as a recordsource even though I
have closed the form before running it. I solved the problem by passing
the user to a new form with a "click this button to complete" message on
it , where the code executes no problem.

This is really clunky though but seemingly necessary.


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: oom | last post by:
I am a bit of a newbie when it comes to python, when working with lists today I noticed some very odd behaviour, any suggestions welcome: Python 2.2.3 (#1, Nov 6 2003, 14:12:38) on linux2...
1
by: Earl Anderson | last post by:
I have imported an Excel worksheet into A97/WinXPH which had the new employees names in one field ( in a Last Name,First Name configuration). I wanted to split that one field ( ) into two...
1
by: Don Leverton | last post by:
Hi Folks, I have been given a CD with approx 130 .xls files (bean-counters!) that I would like to import and merge to ONE table (tblTradeshow). The XL files are *similarly*, but not...
10
by: Marizel | last post by:
I'm not sure there's an easy solution to this, but thought I'd ask. I often find myself with a query which I'd like to reuse, but with a different datasource. These datasources generally have...
2
by: Ralph | last post by:
I'm trying to import a range of cells from an Excel spreadsheet into a table in access. The first row contains column labels, but I cannot use those as my field names, both because of their format...
6
by: David Gartrell | last post by:
Hi i'm trying to import an Excel Spreadsheet into Access2000 but the data types for two of the fields in my imported table are being identified incorrectly. Is there a way of using some VB code in...
5
by: Cecilia Bergengruen | last post by:
2 questions: 1)I inserted a menu in an mdi window form. I right clicked on a menu item and pressed edit names. I therefore edited all my menu item names. Then I right clicked and pressed edit...
7
by: Brett Romero | last post by:
I'd like to copy a object1 into object2 so object2 can be manipulated. Object1 is coming form the middle layer into the UI layer. I'd like to rename a field in Object2 from "somethingID" to just...
7
by: Arnold | last post by:
Greetings Gurus, In a mainform's header, I have a combobox named comboStudents. The rowsource for this combobox is: SELECT -999 As StudentID, "<Add New Student>" As FullName, "aaa" As...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.