# MS Access Hates The Irish?

**URL:** https://boards.straightdope.com/t/ms-access-hates-the-irish/77384
**Category:** Factual Questions
**Created:** [August 21, 2001, 5:58pm UTC](https://boards.straightdope.com/t/ms-access-hates-the-irish/77384 "2001-08-21T17:58:22Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![DMark](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@DMark](https://boards.straightdope.com/u/DMark)
#### Post date: [August 21, 2001, 5:58pm UTC](https://boards.straightdope.com/t/ms-access-hates-the-irish/77384/1 "2001-08-21T17:58:22Z")

</div>

I am trying to program an Access database, with pretty good results, except that any time you enter a name like O’Leary, O’Hanlon, O’Reilly, it causes programming errors.  
I know the cause is the Apostrophe in the name - it is code and screws everying up. Removing the apostrophe fixes it right up…however, short of having to write all the names OLeary, OHanlon, OReilly…is there a way to override code and allow the apostrophe in the names?  
I looked through the MS Office help desk archive, and they were not very helpful.  
So I figure, where else but here to find the wisest answers from sage readers.  
Thanks!

---

<div class="post-metadata">

### Author: ![BF](https://avatars.discourse-cdn.com/v4/letter/b/b5ac83/32.png) [@BF](https://boards.straightdope.com/u/BF)
#### Post date: [August 21, 2001, 6:01pm UTC](https://boards.straightdope.com/t/ms-access-hates-the-irish/77384/2 "2001-08-21T18:01:51Z")

</div>

You need to replace a character in the string, use the routine in this link to help you out.  
[http://www.mvps.org/access/strings/str0004.htm](http://www.mvps.org/access/strings/str0004.htm)

---

<div class="post-metadata">

### Author: ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)
#### Post date: [August 21, 2001, 6:05pm UTC](https://boards.straightdope.com/t/ms-access-hates-the-irish/77384/3 "2001-08-21T18:05:15Z")

</div>

MS Access does have some problems with certain characters in text. What you could do is store the part of the name after the “O’” and have a boolean indicating whether or not an “O’” should be placed in front of it for display (I think you can have a query do that in Access SQL).

---

<div class="post-metadata">

### Author: ![evilhanz](https://avatars.discourse-cdn.com/v4/letter/e/ba8739/32.png) [@evilhanz](https://boards.straightdope.com/u/evilhanz)
#### Post date: [August 21, 2001, 6:22pm UTC](https://boards.straightdope.com/t/ms-access-hates-the-irish/77384/4 "2001-08-21T18:22:33Z")

</div>

You couldn’t pick a less inflammatory topic? 🙂

This is an extraordinarily common newbie problem. It’s also common to anyone new to string manipulation. You may find the following resources helpful in your learning process:  
[Dev Ashish’s Access Web](http://www.mvps.org/access/)  
comp.databases.ms-access  
[Access 2000 Developer’s Handbook](http://shop.barnesandnoble.com/booksearch/isbnInquiry.asp?isbn=0782123708)

Additionally, there are several help topics within Access itself. Search on “quotations in expressions”, “quotation marks in strings”. You should find an answer in short order.

The short and simple answer is to replace the single apostrophe with two before allowing it to be processed by your code.

---

<div class="post-metadata">

### Author: ![AHunter3](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ahunter3/32/368_2.png) [@AHunter3](https://boards.straightdope.com/u/AHunter3)
#### Post date: [August 21, 2001, 6:31pm UTC](https://boards.straightdope.com/t/ms-access-hates-the-irish/77384/5 "2001-08-21T18:31:21Z")

</div>

God I’m glad I’m a FileMaker programmer and not an Access programmer!

---

<div class="post-metadata">

### Author: ![evilhanz](https://avatars.discourse-cdn.com/v4/letter/e/ba8739/32.png) [@evilhanz](https://boards.straightdope.com/u/evilhanz)
#### Post date: [August 21, 2001, 6:35pm UTC](https://boards.straightdope.com/t/ms-access-hates-the-irish/77384/6 "2001-08-21T18:35:16Z")

</div>

> [@](#):
>
> \*Originally posted by AHunter3 \*  
> \*\*God I’m glad I’m a FileMaker programmer and not an Access programmer! \*\*

Oh, so **YOU’RE** the one! 🙂

---

<div class="post-metadata">

### Author: ![DMark](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@DMark](https://boards.straightdope.com/u/DMark)
#### Post date: [August 21, 2001, 9:20pm UTC](https://boards.straightdope.com/t/ms-access-hates-the-irish/77384/7 "2001-08-21T21:20:08Z")

</div>

Ach du scheisse…

I took two years of German and it was a snap compared to the little “string” tidbits being referred to above.

Thanks to all for your kind attempts to help, but I was sorta hoping to get a nice “enter (’) on line 14” response, not Boolean logic and NATO missile encryption codes.

I think I’ll just go out and tip Mrs. OLearys cow and call it a day.

Thanks anyway!

---

<div class="post-metadata">

### Author: ![micco](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@micco](https://boards.straightdope.com/u/micco)
#### Post date: [August 21, 2001, 9:46pm UTC](https://boards.straightdope.com/t/ms-access-hates-the-irish/77384/8 "2001-08-21T21:46:33Z")

</div>

The simple answer is to double the single-quotes to keep them from being treated like a delimiter. For example,

SELECT \* FROM tblNames WHERE LastName=‘O’Leary’  
SELECT \* FROM tblNames WHERE LastName=‘O’‘Leary’

The first is a syntax error. The second one will work properly. Note that the second example uses two single-quotes, not one double quote.

Depending on the language you’re using to generate the SQL queries, it may be trivial to double them up. In VBScript, you’d use something like  
lastname = Replace(lastname, “’”, “’’”)  
and then concatenate that in your string. In Perl, it’d be a simple substitution like  
lastname =~ s/’/’’/g;

This issue isn’t unique to Access. Any language that uses SQL has to properly account for single quotes in the data fields, and any language that uses delimiters has to account for including those delimiters in data strings.

---

<div class="post-metadata">

### Author: ![waterj2](https://avatars.discourse-cdn.com/v4/letter/w/858c86/32.png) [@waterj2](https://boards.straightdope.com/u/waterj2)
#### Post date: [August 21, 2001, 9:55pm UTC](https://boards.straightdope.com/t/ms-access-hates-the-irish/77384/9 "2001-08-21T21:55:12Z")

</div>

Just to make it a little clearer, I’ll put **micco** ’s example in [**code][**/code] tags:

```auto

SELECT * FROM tblNames WHERE LastName='O'Leary'
SELECT * FROM tblNames WHERE LastName='O''Leary'

```
