Applying Filter

Evagrius

Registered User.
Local time
Today, 05:57
Joined
Jul 10, 2010
Messages
170
Hi all,

I have a form with two txt boxes. On the Aflter Update event of the first text box, a filter is applies.

On the after Update Event of the second Box, A filter is also applied. However, the filter for the second txtbox removes the filter for the first txtbox.

What I am trying to do is allow the user to filter in the first txtbox, and then if they choose to use the second txt box, to filter on the exisiting records and not start a "NEW" filter. Does that make sense? Can this be done??? Thank you for any help!!
 
So are both text boxes unbound? How do you invoke the filter?
 
Hi Ken,

Yes, both are unbound.

I just assign the filter criteria to a string and filter the string using the value in the txtbox . .

Code:
Me.Filter = strFilter
Me.FilterOn = True
 
Looks like you need to check the text boxes to see if they have values or if they are null and build your filter string based on those results.
 
okay Ken - so then there is no way to keep a previous filter and filter that recordset??
 
I don't think so. The code to do what I suggested is not that complex.

Something like the following may work, I did this in a hurry so I'm not sure...

Code:
if me.txtOne <> "" then
   strFilter = "myFldName1 = " & me.textbox1
end if

if me.txtTwo <> "" then
   if strFilter = "" then
      strFilter = "myFldName2 = " & me.textbox2
   else
      strFilter = strFilter & " and " & "myFldName2 = " & me.textbox2
   end if
end if
 
Ken has it for you. What you do is create a sub on the form and then just call it in both after update events.
 
Bob and Ken - I can't express how grateful I am for the help in this post. I finally have form the way I would like it to work and I could not have done it without your help. You guys are awesome!!
 

Users who are viewing this thread

Back
Top Bottom