Search statement setup

aardvark
Lounger
Posts: 47
Joined: 09 Feb 2010, 11:30
Location: OH USA

Search statement setup

Post by aardvark »

Hi Gang,

It seems like no matter how many times I try to set one of these up, I can't get it right.

rstLegacy.FindFirst "[IN-SSN] = '" & strSSN & "'" And _
"[IN-BENEFIT-CD] = '" & strBenefitCode & "'"

IN-SSN and IN-BENEFIT-CD are text-type fields.

Any and all assistance is greatly appreciated.

Bill K.

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Search statement setup

Post by HansV »

You have placed the keyword And outside the quotes. It should be part of the search string, however:

rstLegacy.FindFirst "[IN-SSN] = '" & strSSN & "' And " & _
"[IN-BENEFIT-CD] = '" & strBenefitCode & "'"
Best wishes,
Hans

User avatar
Charlotte
Her Majesty
Posts: 499
Joined: 19 Jan 2010, 07:13

Re: Search statement setup

Post by Charlotte »

aardvark wrote:rstLegacy.FindFirst "[IN-SSN] = '" & strSSN & "'" And _
"[IN-BENEFIT-CD] = '" & strBenefitCode & "'"
You seem to have some extra quotes in your statement and a missing ampersand. Try this:

Code: Select all

rstLegacy.FindFirst "[IN-SSN] = '" & strSSN & "' And " _
& "[IN-BENEFIT-CD] = '" & strBenefitCode & "'"
Charlotte

aardvark
Lounger
Posts: 47
Joined: 09 Feb 2010, 11:30
Location: OH USA

Re: Search statement setup

Post by aardvark »

Thank you Charlotte and Hans. I'm back in business. Have a nice weekend.

Bill K.