Search Form Syntax

J

JK

I’m trying to search more than one field using only one field in my search
form.

Search Form

Name:
Address:
Phone:

When a user enters a number in the phone number search field, I want the
form to not only search for matching phone numbers but also fax numbers,
mobile numbers, etc.

This is what I have but it doesn’t work. I commented the two lines that I
tried to add out because again, don’t work. Would someone be able to help me
with the proper syntax?

' Do Phone Number next
If Not IsNothing(Me.txtPhone) Then
' .. build the predicate
varWhere = (varWhere + " AND ") & "[PhoneNumber] LIKE '" &
Me.txtPhone & "*'"
'varWhere = (varWhere + " AND ") & "[FaxNumber] LIKE '" &
Me.txtPhone & "*'"
'varWhere = (varWhere + " AND ") & "[MobilePhone] LIKE '" &
Me.txtPhone & "*'"
End If

Jason
 
P

Paolo

Hi JK,

if you wanna search the condition in one of thwe three field you must or the
conditions. If you and them all the three must be verified so

If Not IsNothing(Me.txtPhone) Then
' .. build the predicate
varWhere = (varWhere + " AND (") & "[PhoneNumber] LIKE '" &
Me.txtPhone & "*'"
'varWhere = (varWhere + " OR ") & "[FaxNumber] LIKE '" &
Me.txtPhone & "*'"
'varWhere = (varWhere + " OR ") & "[MobilePhone] LIKE '" &
Me.txtPhone & "*')"
End If
I think in this way should work.
I assume that here varWhere = (varWhere + " AND
varwhere already contains some conditions 'cause you concatenate it whit an
and to the rest.
HTH Paolo
 
J

JK

Thx so much! Worked perfectly!


Paolo said:
Hi JK,

if you wanna search the condition in one of thwe three field you must or the
conditions. If you and them all the three must be verified so

If Not IsNothing(Me.txtPhone) Then
' .. build the predicate
varWhere = (varWhere + " AND (") & "[PhoneNumber] LIKE '" &
Me.txtPhone & "*'"
'varWhere = (varWhere + " OR ") & "[FaxNumber] LIKE '" &
Me.txtPhone & "*'"
'varWhere = (varWhere + " OR ") & "[MobilePhone] LIKE '" &
Me.txtPhone & "*')"
End If
I think in this way should work.
I assume that here varWhere = (varWhere + " AND
varwhere already contains some conditions 'cause you concatenate it whit an
and to the rest.
HTH Paolo

JK said:
I’m trying to search more than one field using only one field in my search
form.

Search Form

Name:
Address:
Phone:

When a user enters a number in the phone number search field, I want the
form to not only search for matching phone numbers but also fax numbers,
mobile numbers, etc.

This is what I have but it doesn’t work. I commented the two lines that I
tried to add out because again, don’t work. Would someone be able to help me
with the proper syntax?

' Do Phone Number next
If Not IsNothing(Me.txtPhone) Then
' .. build the predicate
varWhere = (varWhere + " AND ") & "[PhoneNumber] LIKE '" &
Me.txtPhone & "*'"
'varWhere = (varWhere + " AND ") & "[FaxNumber] LIKE '" &
Me.txtPhone & "*'"
'varWhere = (varWhere + " AND ") & "[MobilePhone] LIKE '" &
Me.txtPhone & "*'"
End If

Jason
 

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