Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding quotes/double quotes to Access DB

Status
Not open for further replies.

msmith425

MIS
Jan 29, 2002
15
0
0
US
I have a form that the user enters info into and sometimes that info might contain a quote or double quote. I'm trying to find out how to enter these quotes into an Access db so that the information viewed in the database looks normal.

I have been able to change the quotes to a character code such as chr(39). This is OK, but makes viewing the db difficult when viewing the db directly (not through a web page).

Thanks in advance for your help.
 
Try replacing the single quotes with two single quotes:

Replace(string,"'","''")

Instead of 'O'Donnell' you will get 'O''Donnell', which will be displayed in your database correctly.

If your string values are contained within single quotes, having double quotes in the strings shouldn't matter.

 
Thank you JuanitaC! That works great!

Now I have a problem displaying a double quote in an input text box.

If I have something like:

5/8" dia. tube

When it is called from the DB it looks like:

5/8

Seems like everything from the double quotes on is removed. It is still in the DB correctly, but just not displaying correctly.

My code for the input box is:

<input type=&quot;text&quot; name=&quot;Description&quot; size=&quot;43&quot; value=&quot;<%=oRS(&quot;Description&quot;)%>&quot;></td>

Any suggestions?

Thanks.
 
The problem is that the browser is seeing that double quote, assuming your done with the value string, and then throwing the rest away as junk. This is supposed to be a feature :)
What you can do to solve this is:
Code:
<input type=&quot;text&quot; name=&quot;Description&quot; size=&quot;43&quot; value=&quot;<%=Replace(oRS(&quot;Description&quot;),&quot;&quot;&quot;&quot;,&quot;&quot;&quot;)%>&quot;></
This will replace your quotes with the quote escape character. The reason you have 4 &quot;s in a row in the second argument oif the replace function is to escape the double quote in ASP.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
argh. So much for code tags, that should have been:
Code:
<input type=&quot;text&quot; name=&quot;Description&quot; size=&quot;43&quot; value=&quot;<%=Replace(oRS(&quot;Description&quot;),&quot;&quot;&quot;&quot;,&quot;&_q_u_o_t_;&quot;)%>
without the underscores.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top