Solved

How do I remove a carriage return from a text field.

Posted on 2008-06-09
14
516 Views
Last Modified: 2013-12-25
The field contains characters that I think are carriage returns.  The character looks like a square.  I cannot do a Find and Replace.  I'm able to highlight and copy the character into notepad, but that's about all I am able to do with it.  I would like to determine what the character is for certain and I would like to be able to replace it with a space or some other punctuation.
0
Comment
Question by:sharringtoncpa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
14 Comments
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 21747367
Select ID, Asc(Right(FieldInQuestion),1) From Table1

should give you the Ascii number of the last character.

To remove them:

CurrentDB.Execute "Update Table1 Set FieldInQuestion = left(FieldInQuestion,len(FieldInQuestion)-1)"

Mike
0
 

Author Comment

by:sharringtoncpa
ID: 21747381
I'm sorry, I should have stated my question more clearly.  The character is not the last character in the field.  There are several of these characters spread out throughout the data in the field.
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 21747450
Find Ascii number of each like

Select ID, Asc(Mid(FieldInQuestion),12,1) From Table1 Where ID =38

where the funny character is licated in position 12 for a certain record (with ID= 38). Now you have its ascii number, say it is 13, then:

CurrentDB.Execute "Update Table1 Set FieldInQuestion = Replace(FieldInQuestion, chr(13),"")"

Then fish for the next caracter you want get rid of.

Mike
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sharringtoncpa
ID: 21747532
Hi Mike, this solution looks to be exactly what I need, but could you provide more detail.  I have very little experience with VB or VBA.  Could you give me the steps I would need to take to use your code.  

I have also attached a small sample of the database referred to in my question.  The field with the character I'm looking to remove is "Attendee_List".  You could probably do it faster than you could explain it to me so that I would understand.

Thanks for your help with this issue.  I apologize in advance for my lack of knowledge in this area.
0
 

Author Comment

by:sharringtoncpa
ID: 21747560
I ran the following query using sql view:
Select ID,  Asc(Mid(Attendee_List),48,1) From datatest Where ID =3
and I got an error message:  "Wrong number of arguments used with function in query expression"
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 21747641
Asc(Mid(Attendee_List),48,1)

change to

Asc(Mid(Attendee_List,48,1))
0
 

Author Comment

by:sharringtoncpa
ID: 21747863
That worked better. It returned a value of 10 for the character I am looking to replace.  Now how do I run the code you provided.  Is it a macro or module or something else.

CurrentDB.Execute "Update datatest Set Attendee_List = Replace(Attendee_List, chr(10),"")"

Also, in this code it looks like chr 10 is going to be replaced with "".  If I wanted to replace it with something else like a semi-colon, do I have to use the chr value for semi-colon.

Thanks for your help.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 21748211
CurrentDB.Execute "Update datatest Set Attendee_List = Replace(Attendee_List, chr(10),";")"

or maybe:

CurrentDB.Execute "Update datatest Set Attendee_List = Replace(Attendee_List, chr(10),"|")"


by the way, chr(10) is a Line_Feed character.  Chr(13) is a Carriage_Return character

and Chr(13)+Chr(10) is a Carriage_Return+Line_Feed (appears as two small squares one right next to the other) - A Windows NewLine
0
 

Author Comment

by:sharringtoncpa
ID: 21748242
I checked a couple of characters and they are all chr 10 to replace the chr 10 line feed character with a semicolon.

How do I execute the line of code in access?

CurrentDB.Execute "Update datatest Set Attendee_List = Replace(Attendee_List, chr(10),";")"

0
 
LVL 34

Accepted Solution

by:
Mike Eghtebas earned 400 total points
ID: 21748334
sharringtoncpa,

Back from the Gym,

In a module, you can have:

Sub RunMyRoutine()
    CurrentDB.Execute "Update datatest Set Attendee_List = Replace(Attendee_List, chr(10),";")"
End Sub

while the cursor at Current.... line, hit on F8.   "Sub RunMyRoutine()" will get yellow highlighted. And then hit F8 again and again until it reaches to End Sub.

You can also have it in OnClick event of a button.

Mike
0
 

Author Comment

by:sharringtoncpa
ID: 21754264
Hi Mike,

Thanks for your help.  It worked perfectly.

Scott
0
 

Author Closing Comment

by:sharringtoncpa
ID: 31465586
Thanks for your help.  It worked great and it saved me a lot of time.
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 21754424
Glad to help.

Mike
0
 

Author Comment

by:sharringtoncpa
ID: 24009619
The attached file charactertest2.mdb replaces the file I attached in comment #21747532.
charactertest2.mdb
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

726 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