Two Field Search Criteria

F

Fred

Experienced on Access, very newbie on code

Looking to put something on a form to allow search for a record which meets
criteria for two fields. For example:

Enter the first few letters of their CompanyName (requiring user to enter
wildcard is OK e.g. General*)
Enter their city

It could either find the first record which meets those criteria or filter
for all records which meet that criteria, whichever is simplest. Any other
details could be just whatever is easiest

Any help would be appreciated

Fred
 
E

ErezM via AccessMonster.com

hi

filtering is shorter in code:

say there's a button clicked to activate the search:

Me.Filter = "CompanyName Like '*" & txtCompany & "*' And City='" & txtCity &
"'"
Me.FilterOn = True

notice that this way, the user doesnt have to add wildcards, they are added
in code. (on both sides of the string, you can decide if you need it)

the city matching is exact. you can of course change it to approximate just
like the company, if you need

pay attention to the single and double quotes use! (the resulting of the
above might be

CompanyName Like '*General*' And City='New York'

good luck
Erez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top