Connecting Tech Pros Worldwide Forums | Help | Site Map

rs.FindFirst question

Shyguy
Guest
 
Posts: n/a
#1: Nov 13 '05
Is there a way to use this when entries have an apostrphe in them?

Like Joe's Bar and Grill.

Tom van Stiphout
Guest
 
Posts: n/a
#2: Nov 13 '05

re: rs.FindFirst question


On Wed, 26 Oct 2005 00:02:06 -0400, Shyguy <shyguy@aol.com> wrote:

Yes: double-up on them:
rs.FindFirst "LastName='O''Brien"

-Tom.

[color=blue]
>Is there a way to use this when entries have an apostrphe in them?
>
>Like Joe's Bar and Grill.[/color]

lylefair
Guest
 
Posts: n/a
#3: Nov 13 '05

re: rs.FindFirst question


I think your answer is correct.

Shyguy
Guest
 
Posts: n/a
#4: Nov 13 '05

re: rs.FindFirst question


On Tue, 25 Oct 2005 21:21:06 -0700, Tom van Stiphout
<no.spam.tom7744@cox.net> wrote:
[color=blue]
>On Wed, 26 Oct 2005 00:02:06 -0400, Shyguy <shyguy@aol.com> wrote:
>
>Yes: double-up on them:
>rs.FindFirst "LastName='O''Brien"
>
>-Tom.
>
>[color=green]
>>Is there a way to use this when entries have an apostrphe in them?
>>
>>Like Joe's Bar and Grill.[/color][/color]


Thank you for the reply.

I guess there are other ways to use "rs.FindFirst" . ;-( I am using it
behind a combo box and the full line is -

rs.FindFirst "[Organization] = '" & Me![cboOrg] & "'"

Some of the names hgave an apostrophe but some don't. The ones that
don't work fine. When one is selected that has an apostrophe I get a
runtime error 3077 and syntax error (missing operator) in expression.
Tim Marshall
Guest
 
Posts: n/a
#5: Nov 13 '05

re: rs.FindFirst question


Shyguy wrote:
[color=blue]
> I guess there are other ways to use "rs.FindFirst" . ;-( I am using it
> behind a combo box and the full line is -
>
> rs.FindFirst "[Organization] = '" & Me![cboOrg] & "'"[/color]

Don't mean to jump in on Tom, but don't use the single quotes where
you're using them now. Do this:

rs.FindFirst "[Organization] = """ & Me![cboOrg]) & """"

Or, as doubling up on double quotes can get hard to keep track of for
long strings (the chr(34) is a ":

rs.FindFirst "[Organization] = " & chr(34) & Me![cboOrg]) & chr(34)

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Shyguy
Guest
 
Posts: n/a
#6: Nov 13 '05

re: rs.FindFirst question


On Wed, 26 Oct 2005 14:56:41 -0230, Tim Marshall
<TIMMY!@PurplePandaChasers.Moertherium> wrote:
[color=blue]
>Shyguy wrote:
>[color=green]
>> I guess there are other ways to use "rs.FindFirst" . ;-( I am using it
>> behind a combo box and the full line is -
>>
>> rs.FindFirst "[Organization] = '" & Me![cboOrg] & "'"[/color]
>
>Don't mean to jump in on Tom, but don't use the single quotes where
>you're using them now. Do this:
>
>rs.FindFirst "[Organization] = """ & Me![cboOrg]) & """"
>
>Or, as doubling up on double quotes can get hard to keep track of for
>long strings (the chr(34) is a ":
>
>rs.FindFirst "[Organization] = " & chr(34) & Me![cboOrg]) & chr(34)[/color]


Thank you very much. It worked fine, after I removed the extra )
;-)
Trevor Best
Guest
 
Posts: n/a
#7: Nov 13 '05

re: rs.FindFirst question


Shyguy wrote:[color=blue]
>
> Thank you very much. It worked fine, after I removed the extra )
> ;-)[/color]

Until you get one with a double quote in it, say the organisation is the
over 6'5" club :-)

Try:
rs.FindFirst "[Organization] = '" & Replace(Me![cboOrg]"'","''") & "'"
Closed Thread


Similar Microsoft Access / VBA bytes