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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apostrophe in a title

Status
Not open for further replies.

Phudsen

Technical User
Mar 7, 2003
136
A2
Hi,

I have a form that has been working fine until a searched for a title with an apostrophe. The form gave an error. How to avoid that. Suppose I am looking for Penguin's Medical Dictionary . This is the filter code I am using which is working fine for titles without apostrophe.

Set rs = Me.Recordset.Clone
rs.FindFirst "[Title] = '" & Me![Combo64] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.Qty.SetFocus


Thank you
Pauling
 
Hi!

For DAO recordsets, like this, you should be able to do that with double quoting:

[tt] rs.FindFirst "[Title] = """ & Me![Combo64] & """"[/tt]

Roy-Vidar
 
Thank you Roy for you quick accurate and to the point reply

It is working fine.

Would you please explain why """ were able to solve it.

Thanks
Paulin
 
I'm not really sure, to be honest. I rarely work with DAO (except for some form recordset manipulation), and apostrophes isn't really an issue where I live. I've just read it, tested it to verify that it indeed works, and that's it. I'm just observing that when using a debug.print on a string, the double quotes occurs within the string, not single quotes as "usual" (so using chr(34) should probably also work).

Roy-Vidar
 
How are ya Phudsen, Roy . . . .

I always keep a public constant in a module just for just this purpose.

[blue]Public Const DQ As String = """"[/blue] Thats 4 double quotes.

Then I just:
rs.FindFirst "[Title] = " & DQ & Me![Combo64] & DQ

[blue]Phudsen![/blue] In Access VBA help, look for [purple]Quotation Marks In Strings[/purple]. Apostrophe's can raise hell in SQL as you've found out.

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top