Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ' in a name (Access03)

    I am using a combo box to locate records using the Access created coding as below.

    Private Sub Combo2_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[Division] = ' " & Me![Combo2] & " ' "
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub

    I am selecting a Division with the combo box and assigning departments to that division. The problem is that one of the Divisions has a ' in it's name: Women's Pavilion. I can't get it to work. I think I need to add quotes, but I can't get it to work. Thank you.

    Fay

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ' in a name (Access03)

    If none of the divisions contain a double quote <code>"</code>, you can use
    <code>
    rs.FindFirst "[Division] = " & Chr(34) & Me![Combo2] & Chr(34)
    </code>
    Chr(34) represents the double quote character. If you have both single and double quotes in the entries, it becomes a little bit more complicated; let me know if you need that.

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ' in a name (Access03)

    That is exactly what I needed thank you! Fay

  4. #4
    Star Lounger
    Join Date
    Jan 2002
    Location
    Washington State
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ' in a name (Access03)

    Hans,

    I just came across this post while doing a search.

    I have a situation exactly like this except I need to search on fields including single and double quotes.

    How much more complicated does it get to handle both? [img]/forums/images/smilies/smile.gif[/img]

    Thanks,
    Sam

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ' in a name (Access03)

    Using the same expression as in my previous reply:
    <code>
    rs.FindFirst "[Division] = " & Chr(34) & Replace(Me![Combo2], Chr(34), Chr(34) & Chr(34)) & Chr(34)
    </code>
    The Replace function replaces all double quotes " within the value of Combo2 with two double quotes "".

  6. #6
    Star Lounger
    Join Date
    Jan 2002
    Location
    Washington State
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ' in a name (Access03)

    This works great!

    Thanks, Hans!
    Sam

Posting Permissions

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