Hello all!
I am very new to Access and have managed to run into a road block of sorts. I have a very simple query created that pulls from a table in an access 2010 database. I then have an equally simple form named "testform" that has a single combobox named "ComboAnimalType" and a run query button. The combobox has 3 choices, which were manually entered. Dog, Cat and All. In my table, I have a field called Animal, which lists 10 different types of animals, 2 of which are Dog and Cat.
For now, I want "Cat" and "All" to be treated the same way. If either of the options are selected, I want it to be as if there is nothing in the query's criteria for that field. Put another way, I want it to display everything.
When I select "Dog", I want the query to be limited based on the criteria that animal = Dog.
Using an IIF expression, I am able to accomplish the Dog portion. The problem that I am running in to is that I can not seem to figure out how to make the false portion of the IIF display all. I have tried the following, all of which work when the combobox is set to Dog, but return nothing when the combobox is set to Cat or All.
IIf([forms]![testform]![ComboAnimalType]="Dog","Dog","*")
IIf([forms]![testform]![ComboAnimalType]="Dog","Dog",)
IIf([forms]![testform]![ComboAnimalType]="Dog","Dog","")
IIf([forms]![testform]![ComboAnimalType]="Dog","Dog",<>null)
IIf([forms]![testform]![ComboAnimalType]="Dog","Dog",<>"null")
IIf([forms]![testform]![ComboAnimalType]="Dog","Dog",Like "*")
IIf([forms]![testform]![ComboAnimalType]="Dog","Dog",*)
Just to check to see if I had the IIF completely wrong, I changed it to
IIf([forms]![testform]![ComboAnimalType]="Dog","Dog","Cat")
This works just fine to limit the query based on animal being Cat, if anything other than Dog is selected in my combobox, so I know that the expression is in the right order, I am just puzzled as to what I need to use in order to show all results when false.
If you could provide any assistance, I would greatly appreciate it.
Thank you!
James