SQL = ". .like '" & Mike's Garage & "*'"

Posted on 1998-11-19
Last Modified: 2006-11-17
Variable = "Mike's Garage"
SQL = " '" & Variable & "*'". . the variable used contains a possesive "Mike's" which fouls up the SQL statement because of the apostrophe.  How can I parse this out so the SQL looks for the record, since the record says "Mike's Garage" not "Mikes Garage".  The SQL statement, because of the apostrophe in the name, stops at 'Mike' looking for an operator.  help help.
Question by:RUSTY
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3

Author Comment

ID: 1445660
Edited text of question

Author Comment

ID: 1445661
Edited text of question

Author Comment

ID: 1445662
Edited text of question
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

LVL 18

Accepted Solution

deighton earned 30 total points
ID: 1445663
instead of the ' use ''
LVL 18

Expert Comment

ID: 1445664
'Heres a function to put in the extra ' where it is needed

Private Function boggle(s As String) As String

    Dim stemp As String
    Dim c As Integer

   For c = 1 To Len(Text1)
 If Mid(Text1, c, 1) = "'" Then        'NB the "'" is <double quote><single Qt><dbl quote>
            stemp = stemp & "'"      'quote sequence as above
        End If
        stemp = stemp & Mid(Text1, c, 1)
    boggle = stemp

End Function

LVL 18

Expert Comment

ID: 1445665
I need to be clearer because of the way it looks on screen where you have say

O'Brien you must change the ' to two adjacent single quotes i.e ' followed by ' (rather than double quotes)  my function boggle does this for you, once youve boggled your string use it in your sql.

Author Comment

ID: 1445666

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question