J
Jael
Background:
I have a database that records responses to a survey.
Most questions have multiple responses.
The responses are True or False (with False the default) only.
More than one response can be selected True for each question.
There are 20+ questions with responses ranging from 3 to 44.
Sample Question:
Q10 What program languages do you use:
1. VB
2. C++
3. Forth
4. Assembly
5. Other
I use a single numeric entry in my data table for each question and code the
responses as follows:
Question 10 has 5 possible answers. The table entry is called Q10 and data
would be bit coded as:
If Q10Ans1 is True then Q10 = Q10 OR 2^0
If Q10Ans2 is True then Q10 = Q10 OR 2^1
If Q10Ans3 is True then Q10 = Q10 OR 2^2
If Q10Ans4 is True then Q10 = Q10 OR 2^3
If Q10Ans5 is True then Q10 = Q10 OR 2^4
This “sets†the individual bit positions in Q10 based on the response.
E.g, if Q10 =3 then response 1 and 2 (bit positions 0 and 1) were selected.
To clear the response-bit, I replace the OR with XOR.
To test each response I use (Q10 and 2^n)<>0. Where n = bit position (0 – 4)
or response (1 – 5)
My question is:
When I build a report, I use VBA to populate the detail and that works fine
but I’d like to do logical comparisons in the SQL builder using AND, XOR or
OR but them seem not to produce the results I need.
That is, if I have a filter value = IIF((Q10 AND 1)<>0,â€Trueâ€,â€Falseâ€). I
get a True whenever Q10 has any value and False when Q10 is empty. Is this a
function of the “IFF†operator or are logical operations not valid. Or am I
just coding it wrong?
Thanks,
Jael
I have a database that records responses to a survey.
Most questions have multiple responses.
The responses are True or False (with False the default) only.
More than one response can be selected True for each question.
There are 20+ questions with responses ranging from 3 to 44.
Sample Question:
Q10 What program languages do you use:
1. VB
2. C++
3. Forth
4. Assembly
5. Other
I use a single numeric entry in my data table for each question and code the
responses as follows:
Question 10 has 5 possible answers. The table entry is called Q10 and data
would be bit coded as:
If Q10Ans1 is True then Q10 = Q10 OR 2^0
If Q10Ans2 is True then Q10 = Q10 OR 2^1
If Q10Ans3 is True then Q10 = Q10 OR 2^2
If Q10Ans4 is True then Q10 = Q10 OR 2^3
If Q10Ans5 is True then Q10 = Q10 OR 2^4
This “sets†the individual bit positions in Q10 based on the response.
E.g, if Q10 =3 then response 1 and 2 (bit positions 0 and 1) were selected.
To clear the response-bit, I replace the OR with XOR.
To test each response I use (Q10 and 2^n)<>0. Where n = bit position (0 – 4)
or response (1 – 5)
My question is:
When I build a report, I use VBA to populate the detail and that works fine
but I’d like to do logical comparisons in the SQL builder using AND, XOR or
OR but them seem not to produce the results I need.
That is, if I have a filter value = IIF((Q10 AND 1)<>0,â€Trueâ€,â€Falseâ€). I
get a True whenever Q10 has any value and False when Q10 is empty. Is this a
function of the “IFF†operator or are logical operations not valid. Or am I
just coding it wrong?
Thanks,
Jael