Parameter Query based on combo box with "blank" as an option

hockey8837

Registered User.
Local time
Yesterday, 21:58
Joined
Sep 16, 2009
Messages
106
I'm trying to build a query that will return or exclude data based on a combo box.

Basically, have two values I want to sort by: [TargetPlantingDate] and [OwnerResponse].

These two values will pull contact records to generate a mailing list. I have been trying to model off another form/query setup I have where the user could select a zip code to filter or leave blank to return all records. But I need this the other way around- where if the user selects "Yes" from [OwnerResponse] the query will EXCLUDE all "yes" (we want to contact people who haven't said 'yes'), and if they leave the field blank, it will return only those who have not responded (or possibly said no-not absolutely necessary right now, but would be ideal-we usually just leave blank and looking at what we have, I don't actually see any 'no's for any records, but we might in the future). Finally, having an 'All' option would be ideal, too.

I've built my Query where I have
[TargetPlantingDate]: Criteria = [Forms]![frmCDBGMailings]![cbodate]; Or = [Forms]![frmCDBGMailings]![cbodate]

[OwnerResponse]: Or = [Forms]![frmCDBGMailings]![cboOwner]

[AltResponse]: Criteria = Is Null; Or = Is Not Null

Right now, the way I have this set up above, it will return ALL records of the [TargetPlantingDate] selected when I leave "cboOwner" is left blank, and will return only those with "cboOwner" value "yes" when I select "yes" from the value list (which is the only option in the value list, currently).

So, how do I get it to return "blank" results to me when nothing is selected, or alternatively exclude "yes" results when "yes" is selected?
 
I did not understand your code as written but to achieve what you asked your where clause will be

Where
([TargetPlantingDate]= [Forms]![frmCDBGMailings]![cbodate] Or [Forms]![frmCDBGMailings]![cbodate] is null
And
([OwnerResponse] <>[Forms]![frmCDBGMailings]![cbowner] or
[Forms]![frmCDBGMailings]![cbowner] is null)

The is null will mean all values selected if combo is null
If cbowner is yes the all but yes selected

Brian
 
Thanks for the help!
 

Users who are viewing this thread

Back
Top Bottom