Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1998-11-19
7
Medium Priority
?
269 Views
Last Modified: 2006-11-17
Variable = "Mike's Garage"
SQL = "..like '" & 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.
0
Comment
Question by:RUSTY
[X]
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
7 Comments
 

Author Comment

by:RUSTY
ID: 1445660
Edited text of question
0
 

Author Comment

by:RUSTY
ID: 1445661
Edited text of question
0
 

Author Comment

by:RUSTY
ID: 1445662
Edited text of question
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 18

Accepted Solution

by:
deighton earned 120 total points
ID: 1445663
instead of the ' use ''
0
 
LVL 18

Expert Comment

by:deighton
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)
       
    Next
   
    boggle = stemp

End Function

0
 
LVL 18

Expert Comment

by:deighton
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.
0
 

Author Comment

by:RUSTY
ID: 1445666
Brilliant!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

715 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