473,396 Members | 1,757 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,396 software developers and data experts.

Changing field names or setting field names while importing a range of cells from Excel to Access

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 (number,
space, text) and because I've got a whole bunch of similar tables and
I need to have consistant field names in these tables for some data
manipulation I'm doing in VBA.

I've used the following statement to bring the data in with the column
headings as field names:

DoCmd.TransferSpreadsheet acImport, 8, "Mwftest",
"c:\sampleratesheet", True, "page2!a15:d23"

Or I can modify it to create default feild names:

.. . . False, "page2!a16:d23"

However, I don't know how to specify what those field names will be.
I've been working in Access for years, but I'm just now starting to
learn VBA. I've been searching through newsgroup threads and think I
might have found some ways to work around this problem (e.g., rename
the fields in a query). However, that just seems like a sloppier way
to go. Can anyone give me some sample code for this?
Nov 13 '05 #1
2 2892
Hi,

If this is a one-time process, could you import the data stating that the
first row does not contain fieldnames, then Access will assign Field1,
Field2, Field3 etc. Open your new table, delete the first row (the Excel
column headings) and then rename the fieldnames to your liking?

HTH Linda

"Ralph" <ra******@arrowheadcu.org> wrote in message
news:1d**************************@posting.google.c om...
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 (number,
space, text) and because I've got a whole bunch of similar tables and
I need to have consistant field names in these tables for some data
manipulation I'm doing in VBA.

I've used the following statement to bring the data in with the column
headings as field names:

DoCmd.TransferSpreadsheet acImport, 8, "Mwftest",
"c:\sampleratesheet", True, "page2!a15:d23"

Or I can modify it to create default feild names:

. . . False, "page2!a16:d23"

However, I don't know how to specify what those field names will be.
I've been working in Access for years, but I'm just now starting to
learn VBA. I've been searching through newsgroup threads and think I
might have found some ways to work around this problem (e.g., rename
the fields in a query). However, that just seems like a sloppier way
to go. Can anyone give me some sample code for this?

Nov 13 '05 #2
Actually, I need to do this a dozen times every day. Also, I'm trying
to automate this for other users who don't understand the process at
all, so it cannot be a manual process at all.

You're basically describing the second example I gave, ".. . . False,
"page2!a16:d23". I should have actually used a14, one less line to
avoid the headings. This example returns the Field1, Field2, etc. that
you described- That's what I was referring to as "default field names".
I'm looking for a way to set these field names in VBA.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

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

Similar topics

3
by: Michael | last post by:
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...
2
by: Don W. Reynolds | last post by:
Hi All, I am sent an excel spreadsheet on a daily basis. Sometimes it contains 10 rows; sometimes it contains over 5000 rows. I copy this spreadsheet into another spreadsheet and verify the...
4
by: BerkshireGuy | last post by:
I have the following Access code that exports to Excel, inserts a title, changes the color of the title, and then changes the format of several columns to currency. The following code sometimes...
3
by: Janelle.Dunlap | last post by:
I have an Excel spreadsheet containing a column of hyperlinks that I need to import into Access. I have no trouble importing (in my case actually linking) the spreadhsheet to the Access table,...
3
by: D.Stone | last post by:
I'm trying to import an Excel spreadsheet into an existing Access table using Office 2003. Ultimately, the plan is to do it programmatically using TransferSpreadsheet, but to check that the file...
1
by: thadson | last post by:
Hi, I'm trying to import specific cells from MS Excel 2000 spreadsheets to MS Access 2000 tables then move the spreadsheets to a different directory. I'm very new to this and I'm having trouble...
4
by: Bongard | last post by:
I have a dynamic range that I would like to use as a linked table into Access. The problem is that Access doesn't seem to want to to recognize the dynamic range when you click on "show named...
1
by: shenkel55 | last post by:
I am using Access 2003. I've been importing Excel 2003 spreadsheets using the wizard in Access for some time now. The spreadsheet does NOT have the column names in the 1st row, so the wizard names...
2
anoble1
by: anoble1 | last post by:
I have a button in my database that when you hit tit, it imports just 1 excel sheet and puts it in a table. Works great. I am wanting to grab 4 more excel sheets from different locations and store...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.