Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

Remove CRLf in Access Table fields

I have an Access database with a table that has CRLf characters in several columns; 4 to be exact. These are text fields ( I think limited to 200 characters). I need to export this table to a tab delimited text file that I can use to import into a MySQL database.

In working with an EE Expert, it was suggested that I use this Access coding to remove these; this is an example in ONE of the 4 columns (ServiceComments1): Replace(Replace(Nz([ServiceComments1],""),Chr(10)," "),Chr(13)," ")

I did this & the CRFf's are still in the middle of some of the instances, same as before with NO Replace.

Also, prior to doing the Replace, I did a search, Find of chr(10), Chr(13), Vbcr and vblf on the columns; none found in ANY case.

I might be able to edit this out in the resultant text file bu it is tedious & requires it be manually done for over 100 records in total.

Is there a way I can get this done in Access BEFORE I export the table?

Thanks
Avatar of als315
als315
Flag of Russian Federation image

Can you upload DB with some sample records?
string s = string.Empty;
s = replace(s, vbcrlf, " ") 'if it's a CR/LF pair
or

 s = replace (s, chr(10), " " 'if it's just a Line Feed
 or

 s = replace (s, chr(13), " " 'if it's just a Carraige Return
If you post a database with just the table in it holding a couple of records that create multiple records on export, I will examine the table with a hex editor to see what character is actually causing the problem.  Make sure to obscure anything sensitive.

What exactly is the output format you need?  Do you have any flexibility?  A csv file with quoted text fields eliminates the problem of the extraneous crlf's.
Avatar of Richard Korts

ASKER

I did a search (in Access) for vbcrlf; no match.

Previous search shows no match for chr(10) or chr(13).

See attached.

I will try to build a small single table Access database of JUST some of the problem records. It will be a struggle for me because the problem records (obviously) are NOT contiguous.

I am trying to produce a TAB delimited txt file (readable by Excel). I choose this format because data often contains commas, thus csv doesn't work.

Thanks
cant-find-vbcrlf.jpg
As I told you in the other thread, csv DOES work if you select the option to surround the text fields with quotes.  The quotes handle embedded commas but do not solve the problem of CrLf which users frequently put in their text.  There are other characters which could be causing the problem which is why I would like more than one example.
Attached is an excel export of a small portion of the table. The fields that have the CRLF problem within the field are ServiceComments 1, ServiceComments2, Comments1 & Comments2.

In this small sample the only ones that have this issue are the ones with Key 10034, 10048, 10059 & 10082. I do NOT know which of the 4 fields has the problem, but in those 4 records, at least ONE does.

I could not figure put how to build a query & then export to Access; it says you can, but it didn't work.

If you have to have Access, tell my how to export a SMALL portion of a large table into Access. It might be that exporting it to Excel fixes the problem; if it does, I can work with that too.

Thanks
sample1.xlsx
can you make me an empty acess db with a table and the fields - Thanks
There is no problem with the Excel Export.  No additional records were created.

Create a make table query.

SELECT yourtable.*  INTO tempTable
FROM yourtable
WHERE Key = 10034 OR Key = 10048 OR Key = 10059 OR Key = 10082;

Then create a new empty database and import only tempTable.
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To als315,

I looked at your query design; I accidentally ran your update query, then I ran the find, it finds nothing, which I THINK is good.

You query design has a row called Update To: Mine does not. How do I get that row inserted into design view?

Thanks
You should change type of query to update query and manually add "update to" string
User generated image
To als315,

The Update Query actually changes the content of the table, is that correct? I ran it & it said it updated some 12000 records.

Thanks
Yes, table should be updated, now you can search CrLf in your table
Works perfectly!!

Thanks so much, I thought I would NEVER overcome this.