A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Filter multiple fields with one search criteria on form



 
 
Thread Tools Display Modes
  #1  
Old September 17th, 2009, 10:36 PM posted to microsoft.public.access.forms
hlock
external usenet poster
 
Posts: 22
Default Filter multiple fields with one search criteria on form

I have a form with 2 fields - Name1 and Name2. I want to be able to enter
search criteria in my unbound text box and have it check both fields and
return records if the text is in either Name1 OR Name2. Currently, I have it
working for just one field.

If Not IsNull(Me.txtfiltername) Then
strWhere = strWhere & "([Name1] Like ""*" & Me.txtfiltername & "*"")
AND "
End If

How do I get it to search on Name2 as well? Thanks in advance.
  #2  
Old September 17th, 2009, 11:19 PM posted to microsoft.public.access.forms
Kipp Woodard
external usenet poster
 
Posts: 50
Default Filter multiple fields with one search criteria on form

If Not IsNull(Me.txtfiltername) Then
strWhere = strWhere & "([Name1] Like ""*" & Me.txtfiltername & "*"" Or
[Name2] Like ""*" & Me.txtfiltername & "*"") AND "
End If


"hlock" wrote:

I have a form with 2 fields - Name1 and Name2. I want to be able to enter
search criteria in my unbound text box and have it check both fields and
return records if the text is in either Name1 OR Name2. Currently, I have it
working for just one field.

If Not IsNull(Me.txtfiltername) Then
strWhere = strWhere & "([Name1] Like ""*" & Me.txtfiltername & "*"")
AND "
End If

How do I get it to search on Name2 as well? Thanks in advance.

  #3  
Old September 17th, 2009, 11:55 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Filter multiple fields with one search criteria on form

The quotes don't look quite right.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Kipp Woodard" wrote in message
...
If Not IsNull(Me.txtfiltername) Then
strWhere = strWhere & "([Name1] Like ""*" & Me.txtfiltername & "*"" Or
[Name2] Like ""*" & Me.txtfiltername & "*"") AND "
End If


"hlock" wrote:

I have a form with 2 fields - Name1 and Name2. I want to be able to
enter
search criteria in my unbound text box and have it check both fields and
return records if the text is in either Name1 OR Name2. Currently, I
have it
working for just one field.

If Not IsNull(Me.txtfiltername) Then
strWhere = strWhere & "([Name1] Like ""*" & Me.txtfiltername &
"*"")
AND "
End If

How do I get it to search on Name2 as well? Thanks in advance.



  #4  
Old September 18th, 2009, 05:31 PM posted to microsoft.public.access.forms
hlock
external usenet poster
 
Posts: 22
Default Filter multiple fields with one search criteria on form

Works perfect. Thank you for all of your help!!

"Douglas J. Steele" wrote:

The quotes don't look quite right.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Kipp Woodard" wrote in message
...
If Not IsNull(Me.txtfiltername) Then
strWhere = strWhere & "([Name1] Like ""*" & Me.txtfiltername & "*"" Or
[Name2] Like ""*" & Me.txtfiltername & "*"") AND "
End If


"hlock" wrote:

I have a form with 2 fields - Name1 and Name2. I want to be able to
enter
search criteria in my unbound text box and have it check both fields and
return records if the text is in either Name1 OR Name2. Currently, I
have it
working for just one field.

If Not IsNull(Me.txtfiltername) Then
strWhere = strWhere & "([Name1] Like ""*" & Me.txtfiltername &
"*"")
AND "
End If

How do I get it to search on Name2 as well? Thanks in advance.




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:38 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.