From: PeterM on
I have a listbox on a AC2003 form. I want to perform the following DLookup
based on one of the columns/row in the single select listbox. I works great
until the target table column contains a single quote. How do I resolve this
situation?

DLookup("Contents", "OutlookInbox", "Subject = '" & Me.List28.Column(2) &
"'")

Thanks for your help!
From: fredg on
On Wed, 31 Mar 2010 10:11:02 -0700, PeterM wrote:

> I have a listbox on a AC2003 form. I want to perform the following DLookup
> based on one of the columns/row in the single select listbox. I works great
> until the target table column contains a single quote. How do I resolve this
> situation?
>
> DLookup("Contents", "OutlookInbox", "Subject = '" & Me.List28.Column(2) &
> "'")
>
> Thanks for your help!

Here is one method:
= DLookup("Contents", "OutlookInbox", "Subject = """ &
Me.List28.Column(2) & """")
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
From: Duane Hookom on
Replace the single quote with two double quotes:
DLookup("Contents", "OutlookInbox", "Subject = """ & Me.List28.Column(2) &
"""")

--
Duane Hookom
Microsoft Access MVP


"PeterM" wrote:

> I have a listbox on a AC2003 form. I want to perform the following DLookup
> based on one of the columns/row in the single select listbox. I works great
> until the target table column contains a single quote. How do I resolve this
> situation?
>
> DLookup("Contents", "OutlookInbox", "Subject = '" & Me.List28.Column(2) &
> "'")
>
> Thanks for your help!
From: PeterM on
Thank you Duane and Fred... you solutions work perfectly.

Pete

"Duane Hookom" wrote:

> Replace the single quote with two double quotes:
> DLookup("Contents", "OutlookInbox", "Subject = """ & Me.List28.Column(2) &
> """")
>
> --
> Duane Hookom
> Microsoft Access MVP
>
>
> "PeterM" wrote:
>
> > I have a listbox on a AC2003 form. I want to perform the following DLookup
> > based on one of the columns/row in the single select listbox. I works great
> > until the target table column contains a single quote. How do I resolve this
> > situation?
> >
> > DLookup("Contents", "OutlookInbox", "Subject = '" & Me.List28.Column(2) &
> > "'")
> >
> > Thanks for your help!
From: David Kaye on
PeterM(a)discussions.microsoft.com> wrote:

>I have a listbox on a AC2003 form. I want to perform the following DLookup
>based on one of the columns/row in the single select listbox. I works great
>until the target table column contains a single quote. How do I resolve this
>situation?

I got so tired of escaping the single quote character that I just replace it
with the alternate apostrophe, CHR$(146). I trap keystrokes and substitute
the 146 character in the original data entry and I also run a REPLACE function
when importing data from external sources, looping through every field in
every table when importing. To me this is way easier than having to figure
out the escape for single quotes.

(If there's anything I hate about Access (and there isn't much) it's that the
stupid escape sequence. They should have used a backslash or some other rare
character. )