Code for searching 2 different field criteria

Hi. Am trying to search to seperate Access fields from VB but the code I am attempting:

Foo5 = Combo1.Text
Data1.RecordSource = "Select * from Details1 where region = '" & Foo5 & "' and reps ='1'"
        Combo1.Text = "select"

Does the search have to be done using two seperate lines or perhaps my code gramatics is wrong.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

U can do search after assigning the recordsource by using data1.recordset.findfirst method.if any record matches for the given criteria then data1.recordset.nomatch will become false else true.
matt_fennellAuthor Commented:
I have the search working ok. Recordsource has been assigned etc. Just need the code for a dual search where 2 Access fields are queried.

recordsource = "select * from deatails1 where region="my variable"

What else do I need to include in this code? Do I have to search the other field on a different line of code or the same one?
Éric MoreauSenior .Net ConsultantCommented:
Try removing the MoveFirst (there is no need for that line there)!

Also, before the Refresh, what do you see if you add this:
msgbox Data1.RecordSource

Have you tried to run this query into Access?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

matt_fennellAuthor Commented:
Have created a query in Access, what is the code to run it from VB?
Éric MoreauSenior .Net ConsultantCommented:
>>Have created a query in Access, what is the code to run it from VB?

You better keep it in VB! You need to pass parameters to your region field.

But have you tried to run your query exactly like it appears into the message box directly from Access?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
matt_fennellAuthor Commented:
How do you run the query into Access?
Éric MoreauSenior .Net ConsultantCommented:
You create a new query, switch to SQL mode, paste the string and click the Run button.
matt_fennellAuthor Commented:
The msgbox brings up the 'select *' line of code
Éric MoreauSenior .Net ConsultantCommented:
Points to emoreau
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.