Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002
    Location
    Phoenix, AZ
    Posts
    122

    Unanswered: Apostrophie causing problems...

    i have a comb-box that i use on a form to look up a customers info. I have the combo box set like this:

    Sub Combo17_AfterUpdate()
    ' Find the record that matches the control.
    Me.RecordsetClone.FindFirst "[VENDOR] = '" & Me![Combo17] & "'"
    Me.Bookmark = Me.RecordsetClone.Bookmark
    End Sub


    This works great except when there is an apostrophie in the name of the vendor. then i get an error. Is there something i can add to the code to help with this?

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Apostraphy

    Yes, try changing this:

    Me.RecordsetClone.FindFirst "[VENDOR] = '" & Me![Combo17] & "'"

    to this:

    Me.RecordsetClone.FindFirst "[VENDOR] = """ & Me![Combo17] & """"

    replace all ' with "" (2 double quotes)

    There's also another post on this which shows another way to do this instead of using the """.

    Healdem posted this:

    Like " & chr$(34) & (Forms![frmInvoiceSearch]!Description) & chr$(34)

    which avoids the "" problem if the user entered in a ". It's under the post: SQL using Like (posted on 1-29-05.)
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •