I.T. Discussion Community!
-Collapse +Expand
Access
Search Access Group:

Advanced
-Collapse +Expand Access To/From
To/FromCODEGuides
-Collapse +Expand Access Store
PRESTWOODSTORE

Prestwood eMagazine

February Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyMicrosoft Access BoardAccess VBA Programming Topic   Print This     

Replacing quotes with VBA in Access

Replacing quotes with VBA in Access in Access VBA Programming topic (part of our Microsoft Access group).

Quick Search: Replacing   Replacing quotes   Replacing quotes VBA  
Don G
Elgin, IL USA
I am downloading data from a web survey into a txt file that I then import into Access.  Users are inserting "quotes" in their comment fields.  I am cleaning up the comments in the txt file by reading them into variables and using the REPLACE function to remove jargon (e.g. &LF; is replaced withBig Grin!. That works fine, but I have tried to REPLACE the quotes with ^ or single quote but I can't get VBA to read the quotes. I have even used Chr(34) and it is not recognized.  How do I REPLACE quotes in substrings?
 Posted 13 years ago (Thread Starter)
Comment Quote
About Don G -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #12023, 1 replies
Thread Started 7/31/2007 9:54:21 PM
View Counter=7199
Last Reply Posted 8/8/2007 3:44:52 PM)
Location=Elgin, IL USA 
Joined=13 years ago   MB Posts=5  
Most Recent Post
Moderator
Mike Prestwood
Prestwood IT
Prestwood IT office in Citrus Heights, CA

We use the following function in our ASP coding:

Function ConvertQuotesToCode(AText)
 If Len(AText) > 0 Then
  ''' Text with no P blocks are text.
  AText = Replace(AText, "'", "'")
  AText = Replace(AText, """", """)
  
  AText = Replace(AText, "<%", "&#60;&#37;")
  AText = Replace(AText, "%" & ">", "&#37;&#62;")
 End If
  
 ConvertQuotesToCode = AText
End Function

...and this to go the other way:

Function ConvertCodeToQuotes(AText)
 If Len(AText) > 0 Then
  ''' Text with no P blocks are text.
  AText = Replace(AText, "&#39;", "'")
  AText = Replace(AText, "&#34;", """")
  
  AText = Replace(AText, "&#60;&#37;", "<%")
  AText = Replace(AText, "&#37;&#62;", "%" & ">")

 End If
 
 ConvertCodeToQuotes = AText
End Function

Seems to work for us under all circumstances. Try it out and let me know how it goes.

--
Mike Prestwood
Prestwood IT Solutions

 Posted 13 years ago
Comment Quote
About Mike Prestwood -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Mike Prestwood

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Web Presence
Facebook, Prestwood IT Facebook page -- fan page. (Visit Me)
Twitter, Follow Prestwood IT on Twitter. (Visit Me)
LinkedIn, Prestwood IT company page on LinkedIn. (Visit Me)
YouTube, Prestwood IT YouTube Channel (Visit My Channel)
Website, My drum website where I sell my drum books. (http://www.play-drums.com)

Post ID #12041 (Level 1.1)  Reply to 12023
Thread Started 8/8/2007 3:44:52 PM
View Counter=2
Last Reply Posted 8/15/2007 4:17:38 PM)
Location=Prestwood IT office in Citrus Heights, CA 
Joined=20 years ago   MB Posts=1410   KB Posts=1805   KB Comments=69   BLOG, Topics=4  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1242A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #12023 Counter
7199
Since 4/2/2008

Follow PrestwoodBoards on: 


©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech