Search problems with LIKE option

Caitlin11

Registered User.
Local time
Today, 19:35
Joined
Jan 29, 2003
Messages
19
Hello - I have the following problem that I'm hoping someone can help me with.

I have a form that has 3 list boxes as search fields. They are account #, policy # and name. When one of the search fields is filled in and <enter> is pressed it populates the subform below which shows the corresponding records. All 3 search fields were working find until I realized I needed to give the user the ability to enter part of the "name" field and pull up all records with that part. (ie. user enters "RAIN" presses <enter> and the following records come up - Mark Rains, Rainbow Store, Mike Rainer.). I changed the code in the query to allow the user to do this and it worked great. The problem is that after I added this code - the account# and policy # search functions no longer work. If I enter a valid policy # and press <enter> nothing happens. However, if I leave that valid policy # there and also enter a name in the name search field and press <enter> it brings up the appropriate records for the name field AND the record with the corresponding policy # I entered above. Here's the code I have in my query to allow the search to work:

((Mid([mastersearch]![policyno],1,10))=[Forms]![SEARCH2]![combo2]) Or (([mastersearch].[name]) Like "*" & [Forms]![SEARCH2]![combo14] & "*") Or (([mastersearch].[ACCTNO])=[Forms]![SEARCH2]![combo12])

Does anyone have any ideas about what the problem is and how I can fix it?

Thanks in advance for any help!

Caitlin
 
Like "*" & [Forms]![SEARCH2]![combo14] & "*")

If this is a text field you are searching on you need to put the expression within quote marks.

i.e

Code:
Like "*'" & [Forms]![SEARCH2]![combo14] & "*'")
 
Thanks for the help. I did try what you suggested and now the name lookup doesn't work. I can't enter part of a name and have it pull up all corresponding records. However, the account# and policy# lookup now works.

Any other suggestions on how I can get all these of these to work at the same time?

thanks again for your help!

Caitlin
 

Users who are viewing this thread

Back
Top Bottom