Data Types For Excel Import To Access Table

So i am importing data from Excel into an Access table, and this data is overwriting the data (refreshing it) and not appending to.  When I created the table i was careful to define the data types for all the fields to ensure data was brought into the table correctly.  My question is this:  Is there a way as I bring new data (to overwrite) the table that I do not need to go the the exercise of "redefining" each field's data type to ensure (again) data is brought in correctly.  It seems Access wants to determine the data type even though the table it is overwriting has data types defined.  How can I overcome this?  Thanks.  - Tom
LVL 7
tomfarrarAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Developing Solutions LLCCommented:
Generally, when I want to pull data from Excel into Access, I simply link to the Excel data, and then write a query that uses conversion functions to explicitly convert the columns coming from Excel into Access.  Something like:

SELECT cstr(Field1) as Field1
cdbl(Field2) as Field2
cdate(Field3) as Field3
FROM lnk_Excel

Then I use that as the source of the query the will either append or update data in my Access table.
0
NorieAnalyst Assistant Commented:
How are you importing from Excel to Access?

Are you importing directly to the table?
0
tomfarrarAuthor Commented:
I am importing the file directly into the table.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

tomfarrarAuthor Commented:
Dale - That is a thought.  Sounds like there is no option for Access using the data types already defined for the table.
0
Dale FyeOwner, Developing Solutions LLCCommented:
I just prefer not to do the import for precisely the issue you raise.  There is no Import Specification for importing Excel files, so you cannot simply define the columns like you would with an Advanced Import using a CSV file.  For that reason, I prefer to link to the data in Excel, whether it is a worksheet or a range.

I generally perform some data validity tests to make sure I'm not creating orphaned records, or to normalize the data (inserting values into Lookup fields which are not already there), and then I run an UPSERT query to update and insert records. and depending on the situation, maybe a delete query to delete records from the table which are not in the linked Excel file.

This also lets me flag records which have data of the wrong data type, which would not pass the data import process.

Dale
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tomfarrarAuthor Commented:
It is disappointing to me that Access can't (apparently) stick with the data types once established for a table.  Seems like a flaw to me, but maybe there is more to it than I understand.  I was hoping to get other thoughts on options that I had not considered when I submitted the question.  For example, if I were to link the data rather than import it, how would the data types be determined?  Would a formatted text field in an Excel spreadsheet be considered "text" in Access?  How about if the data file was a text file?  How would the data types be considered.

Bottom line I had hoped to get more discussion as I would guess this is a common problem.  Thanks .  - Tom
0
Dale FyeOwner, Developing Solutions LLCCommented:
When linking or importing from an Excel file, Access uses the first 25 (I think) rows to determine what it thinks the datatype of the column should be; sometimes this assessment is wrong.

With text files (delimited via comma, tab, or some other character), you can define an import specification, which tells Access how to treat each column, allowing you to specify the data type of each column, which gives you much greater control of the data import.

Unfortunately, MS has not made it a priority to allow users to create import specifications to use with Excel files.

Dale
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.