I'm tryin to create a form that allows null or *

i have three instances

dbname
cust
rel

if all are * then list all, if dbname is star and others and values miss out dbname.. etc

is there a clever way to build up the sql query instead of lots of iffs