473,396 Members | 1,805 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.

Macro /VBA that imports excel file to table using First row contains header function

Hi, I have an input excel file that needs to be imported to Table1. However, the fieldnames or header in the excel file doesnt match the fieldnames in the database. The fieldnames in the excel file have spaces.
For example: Middle Name (field name in the Excel)
MiddleName (fieldname in the database)

My idea is to import the excel file in the table with First Row contains header option, so I dont have to rename the fields that was given by

Obviously, Ms access doesnt allow field names with space.

Is there a macro or VBA that can import excel file to the table with First row contain s header option so I dont have to rename the input file that I will be getting every month?

Thank you so much!

I am using MS Access 2003
Sep 5 '08 #1
5 5746
NeoPa
32,556 Expert Mod 16PB
In fact Access CAN handle spaces in field names. It's not generally wise to use them, but there are circumstances where their use can be sensible.

Is your problem solved simply by designing the Access table to match?
Sep 5 '08 #2
sorry, Access can allow fielnames to have spaces. However, it doesnt allow fieldnames with period.

I am going to receive access files regularly that may have INVALID fieldnames.

Is is possible to import only the contents of an excel to ms access database?.

So, the range will start at A2.
Sep 8 '08 #3
NeoPa
32,556 Expert Mod 16PB
It's lucky I checked, as I thought there wasn't any way (straightforwardly) within the DoCmd.TransferSpreadsheet() function.

However, look at the Range parameter and you will see that it can be done.

F1 on the DoCmd.TransferSpreadsheet code for the Help on this.
Sep 8 '08 #4
Thank you for your help!
Sep 24 '08 #5
NeoPa
32,556 Expert Mod 16PB
No worries Mary Ann.

I learnt something here too (always a bonus) :)

Welcome to Bytes!
Sep 24 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table....
5
by: Carl | last post by:
Please can anyone tell me how I can create a macro to save the results of a query as an excel file? The query is called Student List and I would like to save it to "My Documents". We have had...
8
by: Nick M | last post by:
Hello All, Excellent info here Thanks! I am very new to using access in general and I am on a learning curve. I'm trying to import an excel workbook (with worksheets) into an access db via a...
0
by: Peter | last post by:
I am having a problem reading an Excel file that is XML based. The directory I am reading contains Excel files that can be of two types. Either generic Microsoft based or XML based. I am reading...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
6
by: Kevin Humphreys | last post by:
Hi There, I am trying to export a recordset to an excel file using the Content Type below in the header. Response.ContentType = "application/vnd.ms-excel" Which works fine however the...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
1
by: baling | last post by:
Hi.... Hi everybody, i have a code that i make in VBA and know I want to use this code in to VB6. But i don't know how to use that code in to VB 6.0 Please correct this code so i can use it in VB...
18
by: Paul Lautman | last post by:
JRough wrote: What do you mean by "redirect the output to Excel"??? Excel isn't a location, it's a spreadsheet program that some (but not all users) will have on their machine. BTW, Location:...
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.