[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Type conversion failure in Access import from Excel

Posted on 2011-10-18
11
Medium Priority
?
1,101 Views
Last Modified: 2012-06-27
Hey Experts!!

I'm not sure exactly how/where to ask the question. I'm doing an import from Excel into Access. The Excel sheet has numbers in a few of the columns, however it keeps giving me the error that I may want to convert certain cells to numbers. If I don't, I'm getting the type conversion failure in Access.

Is there any way to go through the entire Excel sheet and convert numbers to numbers instead of text?  I haven't found a straight forward way to do it properly.
0
Comment
Question by:LZ1
  • 6
  • 3
  • 2
11 Comments
 
LVL 40

Expert Comment

by:als315
ID: 36986217
Sometimes better way to import from Excel through csv and import all columns as text. In this case you can convert them to numbers in access without problems.
0
 
LVL 11

Expert Comment

by:ScriptAddict
ID: 36986853
I have a couple of ways to deal with this,  First... just import it into a blank table in Access, that prevents any type conflicts.  Then you can see what it is trying to import the different columns as, and quickly identify where it doesn't match with your target table.  

if an entire column is the wrong type and you select it you'll see a little alert box just to the top left of the column after you select it.  It often gives me the option to convert the type.

Hope that helps!

0
 
LVL 11

Expert Comment

by:ScriptAddict
ID: 36986878
One of the import steps in Access import is the ability to select the type of data.  If you can't select it there, then just post a copy of the problem column and what format you need it in, and one of us here can easily give you a formula to make the conversion.

-SA
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 30

Author Comment

by:LZ1
ID: 36987365
Well it's not the whole column, but rather certain cells. And even when I do import it into a blank table I still get the errors.
0
 
LVL 11

Expert Comment

by:ScriptAddict
ID: 36987860
Something like this should work.

Sub Test2()
      ' Select cell A2, *first line of data*.
      Range("A2").Select
      ' Set Do loop to stop when an empty cell is reached.
      Do Until IsEmpty(ActiveCell)
         ActiveCell = Evaluate(ActiveCell)
         ' Step down 1 row from present location.
         ActiveCell.Offset(1, 0).Select
      Loop
   End Sub

Open in new window

0
 
LVL 30

Author Comment

by:LZ1
ID: 36987908
Is this Excel?
0
 
LVL 40

Accepted Solution

by:
als315 earned 2000 total points
ID: 36988046
Try to save your excel to text file with delimiters (csv), import (or link it) to some temporary table with all fields marked as text and then create add query with nesessary data conversion.
0
 
LVL 11

Expert Comment

by:ScriptAddict
ID: 36988272
Yes, it's VBA and can be attached to a macro.

Have you tried the value(Ref) formula?  

Something like this: =IF(ISERROR(VALUE(A2)),A2,VALUE(A2))

should work for you.
0
 
LVL 11

Expert Comment

by:ScriptAddict
ID: 36988321
I would create a second worksheet(tab) and use that formula on all the cells, and then import that sheet.
0
 
LVL 11

Expert Comment

by:ScriptAddict
ID: 36988343

=IF(ISERROR(VALUE(ProblemWorksheet!A1)),ProblemWorksheet!A1,VALUE(ProblemWorksheet!A1))

And just copy that over the entire other worksheet starting with Cell A1, and it should import fine.

you'll need to replace "ProblemWorksheet" with the name of the worksheet(tab) that your trying to import.
0
 
LVL 30

Author Closing Comment

by:LZ1
ID: 36989644
So simple, but worked flawlessly.  Thanks
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question