Search Form Syntax

  • Thread starter Thread starter JK
  • Start date Start date
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
 
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
 
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
 
Back
Top