Remove Single Quote

  • Thread starter Thread starter PeterM
  • Start date Start date
P

PeterM

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!
 
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) & """")
 
Replace the single quote with two double quotes:
DLookup("Contents", "OutlookInbox", "Subject = """ & Me.List28.Column(2) &
"""")
 
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. )
 
PeterM said:
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!
 
Back
Top