2 filters

  • Thread starter Thread starter jean.ulrich
  • Start date Start date
J

jean.ulrich

Hi

I have a form with 2 buttons
each one produce a filter

Code on the first one is
Me.Filter = "Unit <> 'Meter'"
Me.FilterOn = True

and the second one is
Me.Filter = "Proj > 0"
Me.FilterOn = True

The problem is that if I click on the first button, I obtain Units
different than 'Meter'
and if i click on the second button I obtain Proj > 0 but Meter comes
back
If I click bach on the first button, I don't have anymore Meter but I
have proj = or < 0
I would like with one click to obtain Unit different than 'Meter' AND
Proj >0
Can both filters be combine and if yes what should I use as code.
I have try many things but without success
thanks
 
Try:
Me.Filter = "(Unit <> 'Meter') AND (Proj > 0)"
Me.FilterOn = True
 
When youy say that you get Units different than Meter, do they have values,
or are they Nulls? To ignore the Nulls, you need to do something like

Me.Filter = "Nz(Unit, "") <> 'Meter'"

To combine filters, you need to AND them together:

Me.Filter = "Nz(Unit, '') <> 'Meter' AND Proj > 0"

What you might want to do is use something like:

If Len(Me.Filter) > 0 Then
Me.Filter = Me.Filter & " AND Nz(Unit, "") <> 'Meter'"
Else
Me.Filter = "Nz(Unit, "") <> 'Meter'"

End If

and

If Len(Me.Filter) > 0 Then
Me.Filter = Me.Filter & " AND Proj > 0"
Else
Me.Filter = "Proj > 0"
End If

You'd also need a ClearFilter option, which would set the Filter to nothing,
and set the FilterOn property to False
 

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

Back
Top