Results 1 to 9 of 9
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Run-time error on search box (XP)

    I've put a search box on a form to help the use locate a particular "donor name." I created the search box (combo box) with the Wizard, so I'm a bit perplexed to get a "Run-time error '3077'

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

    Re: Run-time error on search box (XP)

    There's nothing wrong with the syntax that I can see, unless the combobox is null after the update.
    Charlotte

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: Run-time error on search box (XP)

    Thanks for looking at this, Charlotte. Meanwhile, I built another table to experiment with other approaches to a number of things, and now things are OK. Who knows....

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

    Re: Run-time error on search box (XP)

    Lucas. it's the apostrophe in Peterson's that is causing the trouble. The result of substituting Peterson's Car Wash in<pre>rs.FindFirst "[DonorName] = '" & Me![Combo18] & "'"</pre>

    is<pre>rs.FindFirst "[DonorName] = 'Peterson's Car Wash'"</pre>

    As you can see, there is an odd number of apostrophes/single quotes within the string, this causes an error.

    There are several ways to get around this:

    If you are certain that there are no names containing double quotes, you can use double quotes instead of singles quotes; since double quotes are already used to delimit the find string, you must either use double double quotes or chr(34):<pre>rs.FindFirst "[DonorName] = """ & Me![Combo18] & """"</pre>

    or<pre>rs.FindFirst "[DonorName] = " & Chr(34) & Me![Combo18] & Chr(34)</pre>

    Another possibility is to double the single quotes inside the name:<pre>rs.FindFirst "[DonorName] = '" & Replace(Me![Combo18],"'", "''") & "'"</pre>

    The latter won't work on Access 97, since Replace was introduced in Access 2000 VBA (but you could write your own Replace function...)

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: Run-time error on search box (XP)

    Hello, Hans

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

    Re: Run-time error on search box (XP)

    Are names starting with " the only ones you want to sort differently, or are there other "exceptions"?

  7. #7
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Run-time error on search box (XP)

    You can use VBA functions to replace double-quotes (smart or dumb) with a zero-length string and then sort on the quote-less result. Feel free to refresh your memory by perusing previous thread on this subject:

    <!post=Re: Sorting and quotation marks (97 & XP),233276>Re: Sorting and quotation marks (97 & XP)<!/post>

    Looking over previous thread, using Replace function to replace quotes is still probably simplest way to do this. See previous posts for examples.

    HTH

  8. #8
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: Run-time error on search box (XP)

    Thanks, Mark, for gently refreshing my memory! <img src=/S/blush.gif border=0 alt=blush width=15 height=15> This thread brings back memories from last year. You, Hans, Wendell and others were a huge help! I'll study this stuff again

  9. #9
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: Run-time error on search box (XP)

    Thanks, Hans, but Mark has ever-so-gently steered me back to a thread I started last year. The answers

Posting Permissions

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