Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jan 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    List box control error (VBA) (Access 2000)

    I'm using this VBA script to navigate a recordset:

    rs.FindFirst "[Name_last] = '" & Me![list] contains an appostrophe.

    Is there an easy solution, or should I simply exclude all "O'Connors" from the database??!!

    Thanks,

    Brandon.

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

    Re: List box control error (VBA) (Access 2000)

    If you don't have names containing double quotes, try this:
    <code>
    rs.FindFirst "[Name_last] = " & Chr(34) & Me![list] & Chr(34)
    </code>
    Chr(34) is the double quote ".

  3. #3
    Lounger
    Join Date
    Jan 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List box control error (VBA) (Access 2000)

    You rock!

    Thanks,

    Brandon.

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: List box control error (VBA) (Access 2000)

    What if you have single and double quotes in a field?

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: List box control error (VBA) (Access 2000)

    In the same record or in different records? In the same record, spank the user. In different records, use an InStr to test for the existence of either a chr(34) or a chr(39), which is a single quote. The use whichever one isn't in the field to wrap the text.
    Charlotte

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

    Re: List box control error (VBA) (Access 2000)

    You could use the FixQuotes function from <post#=474008>post 474008</post#>.

Posting Permissions

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