Filtering A Form from a Combo Box

Cavman

Registered User.
Local time
Today, 09:39
Joined
Oct 25, 2012
Messages
66
Hi All,

I have a form that is linked to a query. The query filters the form by pulling criteria for one of the fields from a function. The criteria is fed into the function based on a combo box with options "Team 1", "Team 2", "All Teams".
The issue I have is what to pass through to the function for "All Teams" ie. display all records without filtering. If I send nothing ("") through, it doesn't show anything.
I'm sure it's probably something simple, but I just can't figure it out! Any help would be appreciated.

Thanks,

Simon
 
I thought maybe * might work, but nope, still no joy.
 
Ok, managed to solve my own problem! For anyone else trying to achieve the same thing this is how to do it...

I was thinking along the correct lines with *, just wasn't applying it correctly. You need to use like and concatenate your original criteria variable with *.

So in a query criteria it would take the form of:

Like GetCriteria() & "*"

where GetCriteria is the function that returns your criteria. In a DLookup or DCount it would take the form of:

= DCount("[MyField]", "tbl_MyTable", "[MyFilterField] Like '" & strMyCriteria & "*" & "'")

You can then pass criteria into GetCriteria or strMyCriteria to filter your records, or if you pass "" into them all records will be displayed. Voila!

Simon
 

Users who are viewing this thread

Back
Top Bottom