DoCmd.TransferSpreadsheet not transfering text values

dakota727

Board Regular
Joined
Dec 3, 2006
Messages
164
Office Version
  1. 365
I am using the following to transfer Excel data into a database.

DoCmd.TransferSpreadsheet acImport, 8, "tblRawData", strInputFileName, True, ""

One of the fields [Result] fails to transfer a value when it has a value with a less than symbol (<0.04). The table I am importing into tblRawData has the [result] field formated as a text field so I am not sure why this is a problem. In the excel file that I am inporting there are very few results that are true text values in the form of a less than value with the majority being numbers even though I treat them as text. It is as if Access sees the first 50 or so records and since all the data in the results field appears numeric it wants to treat all of the following results as numeric and gives an inport error once it reaches a value that is actually text.

Has anyone come across this? This seems to be both in ACC2003 and 2007. I assume I can reorde the data in the excel file to work around the issue but I was wondering if anyone has a better solution.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
This an issue with importing Excel data straight into Access. Excel and Access talk to each other and Access tries to "guess" at the format of your data based on what the data in the first n records looks like, and sometimes it guesses wrong. I have pulled my hair out many times trying to get this to work.

What I find is usual easier is to export my Excel file to a text file, and then import that text file into Access. The advantage there is that you can set up an Import Specification that tells Access what the format of every field is in your text file (you cannot do this when importing Excel files directly).

It is an extra step, but it you can spend countless hours trying to figure out how to get the Excel file in with little success. I usually create an Excel macro that automates that piece anyhow.
 
Upvote 0
Thanks for the input. I guess you confirmed what I suspected was the problem. I was thinking my other option was to sort the Excel file so that some of the non numeric results are at the beginning of the file so Access guesses the field type correctly.

Thanks for your suggestion you are probably right that just converting the Excel file to a text file and making my own import specification would solve the issue.

Thanks.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top