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

problem importing excel

the Excel data that I would like to import into Access sometimes contain
line breaks, like this:

623
749

in one cell.
In Access, the imported data looks like this then:

623749

what can I do about this?

-Michael
Sep 12 '06 #1
6 2744
What do you want it to look like in Access?
Do you want the first 3 numbers or the 2nd?

I think you're going to have to format that data in Excel prior to
importing.

Sep 12 '06 #2
What do you want it to look like in Access?
Do you want the first 3 numbers or the 2nd?
I want them to look as they are meant, i.e. like the first 3 numbers

I think you're going to have to format that data in Excel prior to
importing.
they are formatted as text. It doesn't have to do anything with formatting.

The problem is that line breaks in Excel are chr(10) whereas in Access they
are chr(13)chr(10). I need some setting that translates that. If these were
intelligent programs, they would translate it like that by default. <sigh>

-Michael
Sep 12 '06 #3
Michael Peters wrote:
>What do you want it to look like in Access?
Do you want the first 3 numbers or the 2nd?

I want them to look as they are meant, i.e. like the first 3 numbers

>I think you're going to have to format that data in Excel prior to
importing.

they are formatted as text. It doesn't have to do anything with formatting.

The problem is that line breaks in Excel are chr(10) whereas in Access they
are chr(13)chr(10). I need some setting that translates that. If these were
intelligent programs, they would translate it like that by default. <sigh>

-Michael

<sighif the person who created the data in the first place... </sigh>
Oh, heck. We have to deal with these things, right?

Totally untested...

Place in a standard module:

Public Function TruncCHR10(DataIn as String) as String
Dim L as Long
L = Instr(1, DataIn, Chr(10))
TruncCHR10 = DataIn
If L 0 Then
TruncCHR10 = Left(DataIn, L - 1)
EndIf
End Function

After you import the globbed-up data, run an update query along the lines of

UPDATE MBTable.MBData
SELECT TruncCHR10(MBData);

HTH
--
Smartin
Sep 13 '06 #4

Michael Peters wrote:
What do you want it to look like in Access?
Do you want the first 3 numbers or the 2nd?

I want them to look as they are meant, i.e. like the first 3 numbers

I think you're going to have to format that data in Excel prior to
importing.

they are formatted as text. It doesn't have to do anything with formatting.

The problem is that line breaks in Excel are chr(10) whereas in Access they
are chr(13)chr(10). I need some setting that translates that. If these were
intelligent programs, they would translate it like that by default. <sigh>

-Michael
You want some bit of software to read your mind? Hmm... sounds dodgy.
Personally, I'd try to split the stuff out in Excel, or use something
like this:

Public Sub TruncCHR10()
Dim rs As DAO.Recordset
Dim vData As Variant
Dim intCounter As Integer

Set rs = DBEngine(0)(0).OpenRecordset("SELECT PK, NumberList FROM
xlsTestData;", dbOpenForwardOnly)
Do Until rs.EOF
vData = Split(rs.Fields("NumberList"), Chr(10))
For intCounter = LBound(vData) To UBound(vData)
Debug.Print rs.Fields("PK"), vData(intCounter)
Next intCounter
rs.MoveNext
Loop

rs.Close
Set rs = Nothing
End Sub

But instead of just printing the split data to the debug window, write
it to a child table, where it belongs. And then you can query etc
without a clairvoyant computer.

Sep 13 '06 #5
thanks for your help everybody!

I finally managed to solve the problem this way:

The chr(10) only linebreaks in Excel had to be replaced by ordinary
chr(13)chr(10) carriagereturn-linebreaks for Access.

I first exported the sheet into XML. The chr(10) line breaks turned up in
the XML code as &10; - I simply replaced them with &13;&10; using an ascii
editor, and re-imported them into Excel. The result could then be imported
into Access and the line breaks turned up correctly this time.

-Michael
Sep 13 '06 #6
Michael Peters wrote:
thanks for your help everybody!

I finally managed to solve the problem this way:

The chr(10) only linebreaks in Excel had to be replaced by ordinary
chr(13)chr(10) carriagereturn-linebreaks for Access.

I first exported the sheet into XML. The chr(10) line breaks turned up in
the XML code as &10; - I simply replaced them with &13;&10; using an ascii
editor, and re-imported them into Excel. The result could then be imported
into Access and the line breaks turned up correctly this time.

-Michael

Just curious--did you end up with multiple values in a single cell?

--
Smartin
Sep 13 '06 #7

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

Similar topics

4
by: Little PussyCat | last post by:
Hello, I nee to write something that will transfer excel data into an SQL Server table. I have for another database application I wrote have it importing Excel spreadsheet data using cell by...
1
by: Richard Holliingsworth | last post by:
Hello: Thanks for your quick response. I'm trying to import a new Excel file into an A2K table and it's truncating the data. One of the Excel columns is a text field that can be up to 2000...
9
by: Edward S | last post by:
I budget for a Project in an Excel sheet as illustrated below. The months below are usually a 2 year period i.e. 24 months, though it could be over 24 months depending upon a Project. I then...
7
by: Darren | last post by:
I have been attempting to create a reservation planning form in excel that imports Data from an Access database and inserts that information automaticly into the correct spreed sheet and the...
2
by: nutthatch | last post by:
I want to be able to import an Excel spreadsheet into Access 2K using the macro command Transferspreadsheet. However, the file I am importing (over which I have no control) contains some records...
9
by: jillandgordon | last post by:
I am trying to import an excel file into Access 97. It looks perfectly all right but, every time I try to import it, I get to the lst step and am told that it was not imported due to an error. ...
2
by: jereviscious | last post by:
Hi all - Last resort time. I'm importing data from a spreadsheet that I receive from one of my vendor using interop.excel. The date field in excel is entered as 4/7/2006, but when I retrieve...
5
by: hharriel | last post by:
Hi, I am hoping someone can help me with an issue I am having with excel and ms access. I have collected data (which are in individual excel files) from 49 different school districts. All...
4
by: andrewmac | last post by:
I hope someone can help - I am new to Access so please be patient. I have a list of about 100 equity tickers in a column in Excel formatted as Text. I am trying to copy and paste into a field...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.