RYankowitz
Programmer
- Jun 13, 2000
- 27
Help, please... I have hit a brick wall.
I have a need to allow a user to select any or all choices in a group while entering data, such as:
[ ] Food [ ] Water [ ] Air
Elsewhere the user will choose one of the items from that group, which will be used to drive a query to select records containing that (and only that) choice.
How I've done it so far - the way that doesn't work
Each of the choices is contained in an unbound check box, with the first box's value=1, the second=2, the third=4. The sum of the values is stored in the database table's field (call it Essentials).
The idea is to use the logical OR and AND operators to mask the correct bits in Essentials in order to filter out the unwanted records.
The problems?
1. I cannot use AND or OR operators in the criteria row of a Select query, since the query assumes I want to filter this OR that, rather than do a bitwise OR of this/that.
2. I tried using the EVAL() function, which should evaluate the expression first (and does, with most arithmetic functions), but using AND or OR inside it does not work.
3. I am successful putting the logic in a custom Function procedure, and calling that function from the criteria line of the query, but this method is amazingly slow.
So, I repeat: Help, please... I have hit a brick wall.
Perhaps there's another way around the problem you know about?
I have a need to allow a user to select any or all choices in a group while entering data, such as:
[ ] Food [ ] Water [ ] Air
Elsewhere the user will choose one of the items from that group, which will be used to drive a query to select records containing that (and only that) choice.
How I've done it so far - the way that doesn't work
Each of the choices is contained in an unbound check box, with the first box's value=1, the second=2, the third=4. The sum of the values is stored in the database table's field (call it Essentials).
The idea is to use the logical OR and AND operators to mask the correct bits in Essentials in order to filter out the unwanted records.
The problems?
1. I cannot use AND or OR operators in the criteria row of a Select query, since the query assumes I want to filter this OR that, rather than do a bitwise OR of this/that.
2. I tried using the EVAL() function, which should evaluate the expression first (and does, with most arithmetic functions), but using AND or OR inside it does not work.
3. I am successful putting the logic in a custom Function procedure, and calling that function from the criteria line of the query, but this method is amazingly slow.
So, I repeat: Help, please... I have hit a brick wall.
Perhaps there's another way around the problem you know about?