tjb1
tjb1

Reputation: 757

Query - Select value if available, otherwise use specified value

This is my current table ( https://db.tt/1UVjhHCw ) and the form ( https://db.tt/sNzqnEL6 ) and when I enter 00 as the type in the form, I want it to return only records that have 00. If I enter 01 as the type, I want it to return only the records that have XX. 00 and 01 are not constants, there are around 60 different types in the real database.

I've tried using this SELECT PrintList.KEY, PrintList.Family, PrintList.Type, PrintList.Class, PrintList.Shape FROM PrintList WHERE (((PrintList.Family)=Forms!Input!cfamily) And ((PrintList.Type)=IIf((PrintList.Type)=Forms!Input!ctype, Forms!Input!ctype,"XX"))); but it is returning 00 and XX records when the type is set as 00 ( https://db.tt/3RznlRpe ), if the type is XX it only returns records with XX and 01 returns just XX so it seems like if the value is 00 it is doing both but I'm not sure why.

Upvotes: 0

Views: 47

Answers (1)

Emi
Emi

Reputation: 484

May be Changing to this will help.

IIf(Forms!Input!ctype.value = "00", Forms!Input!ctype,"XX")

Upvotes: 1

Related Questions