K
KT Huggs
I am attempting to design a query that will look up records from a single
category or a preset group of categories. I have created a form where the
user may select a category from a list box OR they may select another control
that is SUPPOSED to indicate a preset group of categories (e.g. the
categories with the primary keys of 4, 8 and 17).
If I create an expression for the criteria field in my query (Note:
[RadioButtonCtrl1] is the control that selects the list box choice on the
form)
= IIf (Forms![FormName]![RadioButtonCtrl1], Forms![FormName]![ListCtrl],8)
then it will either return the records for the selected category or the
query will return records for catgory 8 if the preset group control is
selected on the form - as it should.
If I test that my expression for the preset combination only is correct by
creating the expression = 4 Or 8 Or 17, then that also works as expected and
returns all records in those three categories.
BUT when I try and combine both expressions by typing
= IIf (Forms![FormName]![RadioButtonCtrl1], Forms![FormName]![ListCtrl],4 Or
8 Or 17)
then it does not work when I select the "preset group" control and returns
no records. (The list box part works fine.) When I go back to the query,
then I see it has modified the "falsepart" section of the IIf function.
Instead of reading 4 Or 8 Or 17,
it now reads (
.[Field])=4 Or (
.[Field])=8 Or
(
.[Field])=17
(Where
.[Field] is in fact the table and field that the query is
looking up in that column.)
It does the same thing if the 4 Or 8 Or 17 expression is the truepart of the
function as well.
I'm sorry this is wordy, but I really don't know what is going on. It to me
seems that the full expression should function as I wrote it without bugs.
Can someone please tell me what Access is doing and why, and how I can build
an expression to do what I want without Access changing it?
Thanks!!!
category or a preset group of categories. I have created a form where the
user may select a category from a list box OR they may select another control
that is SUPPOSED to indicate a preset group of categories (e.g. the
categories with the primary keys of 4, 8 and 17).
If I create an expression for the criteria field in my query (Note:
[RadioButtonCtrl1] is the control that selects the list box choice on the
form)
= IIf (Forms![FormName]![RadioButtonCtrl1], Forms![FormName]![ListCtrl],8)
then it will either return the records for the selected category or the
query will return records for catgory 8 if the preset group control is
selected on the form - as it should.
If I test that my expression for the preset combination only is correct by
creating the expression = 4 Or 8 Or 17, then that also works as expected and
returns all records in those three categories.
BUT when I try and combine both expressions by typing
= IIf (Forms![FormName]![RadioButtonCtrl1], Forms![FormName]![ListCtrl],4 Or
8 Or 17)
then it does not work when I select the "preset group" control and returns
no records. (The list box part works fine.) When I go back to the query,
then I see it has modified the "falsepart" section of the IIf function.
Instead of reading 4 Or 8 Or 17,
it now reads (
(
(Where
looking up in that column.)
It does the same thing if the 4 Or 8 Or 17 expression is the truepart of the
function as well.
I'm sorry this is wordy, but I really don't know what is going on. It to me
seems that the full expression should function as I wrote it without bugs.
Can someone please tell me what Access is doing and why, and how I can build
an expression to do what I want without Access changing it?
Thanks!!!