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

apostrophes in names

http://www.thescripts.com/forum/thread598894.html

I found solution in the above thread but it did not work in my case. Is there any other way of solving this apostrophe problem?
Apr 23 '07 #1
3 5119
ADezii
8,834 Expert 8TB
http://www.thescripts.com/forum/thread598894.html

I found solution in the above thread but it did not work in my case. Is there any other way of solving this apostrophe problem?
This Function, straight from the Access 2002 Developers Handbook, will handle all problems with apostrophes in names. Simply pass the String to the Function, and it will make it usable in Criteria specification situations. If your Delimiter is not an apostrophe, specify otherwise in the 2nd Argument:
Expand|Select|Wrap|Line Numbers
  1. Public Function adhHandleQuotes(ByVal varValue As Variant, Optional Delimiter As String = "'") As Variant
  2.     ' Replace all instances of a string delimiter with TWO instances,
  3.     ' thereby handling the darned quote issue once and for all. Also,
  4.     ' surround the string with the delimiter, as well.
  5.  
  6.     ' Returns Null if the String was Null, otherwise
  7.     ' returns the String with all instances of strDelimiter
  8.     ' replaced with two of each.
  9.  
  10.     adhHandleQuotes = _
  11.      strDelimiter & _
  12.      Replace(varValue, strDelimiter, strDelimiter & strDelimiter) & _
  13.      strDelimiter
  14. End Function
' adhHandleQuotes("This 'is' a test") returns ==> "'This ''is'' a test'"
Apr 23 '07 #2
Thanks for the help!
Apr 25 '07 #3
NeoPa
32,556 Expert Mod 16PB
Apostophes should only be a problem in SQL strings as VBA uses the double-quote character for string delimiting.
ADezii's solution is perfectly general purpose though. Nice.
May 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: middletree | last post by:
I put in some code to keep apostrophes from being a problem. However, on the display page, they have double quotes. What am I doing wrong? Here is the code on the page which captures the data...
8
by: Joe Van Meer | last post by:
Hi all, Been a while since I've done any asp coding, but happy to be getting back into it. My question is what is the best way (now) to handle apostrophes coming in from forms and going into...
4
by: Lord Merlin | last post by:
When I insert info into a DB from a form, it cuts the string off at the first apostrophe ("). How would I make it insert the data as-is, with the apostrophes? Here is the code used to insert the...
1
by: kalbee | last post by:
When we insert text into field in a table, SQL SERVER apparently replaces apostrophes with question marks -- is there a way to not have this occur? We don't have this happen with the mySQL...
2
by: Poster | last post by:
After creating an IN clause from a bunch of character strings created by a Word macro, Query Analyzer complains about a syntax error. The macro takes a column full of character strings and wraps...
3
by: James Foreman | last post by:
I've got a set of emails in a table, where sometimes they've failed to input the @ properly. Eg james.foreman'abcmail.co.uk How do I write a replace to deal with that? Also, I've got a set...
3
by: Richard Hollenbeck | last post by:
I have an email field and a command button to send email. The problem is that when the email program opens up there are apostrophes around the email address that I have to manually remove before...
5
by: james.igoe | last post by:
History: Took over development of Access project after half of app was developed. Continued the second half using same coding style as first developer, but improved upon code and flow, etc. ...
4
by: Nathan | last post by:
Hi, I'm doing a database app using MS Access and OleDb adapters, and I'm having trouble with getting strings containing apostrophes in and out of the database. I read through a thread below...
4
by: Lucanos | last post by:
Hey Guys, Probably a simple question, but one I am struggling with all the same. I know that in PHP you wrap a text string in apostrophes or quotations - (examples $variable = 'this string' OR...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.