Display text in calculated query field based on multiple checkboxes (2 Viewers)

timbits35

Registered User.
Local time
Today, 04:02
Joined
Nov 3, 2011
Messages
32
I have 3 different yes/no checkboxes.

I would like to create a calculated field in my query that looks at all the checkboxes and displays text based on which checkboxes are selected.

Here are my fields
SpecialSS
SpecialDT
SpecialSGT

So if for example SpecialSS is checked off, I would like the calculated field to display "SS"
If SpecialSS and SpecialDT are both checked off, I would like it to display "SS, DT"

This works for 1 field
IIf([SpecialSS]=True,"(SS)","")

How would I incorporate the rest? I tried using or, but the result gave me -1 in the calculated field.

Thank you
 
How married to your comma separator are you? Would "SS DT" be fine? Or do you need the comma between them when both true?

The easy way is no comma, you just string your Iif's together:
Code:
Trim(IIf([SpecialSS]=True,"SS ") & IIf([SpecialDT]=True,"DT ") & IIf([SpecialSGT]=True,"SGT"))

But if you need that comma this will need to be a user defined function in a module. The logic is a little more involved (nothing horrible, just more of it) which would require more space to write the code for that logic.
 
I have 3 different yes/no checkboxes.

I would like to create a calculated field in my query that looks at all the checkboxes and displays text based on which checkboxes are selected.

Here are my fields
SpecialSS
SpecialDT
SpecialSGT

So if for example SpecialSS is checked off, I would like the calculated field to display "SS"
If SpecialSS and SpecialDT are both checked off, I would like it to display "SS, DT"

This works for 1 field
IIf([SpecialSS]=True,"(SS)","")

How would I incorporate the rest? I tried using or, but the result gave me -1 in the calculated field.

Thank you
Hi
The following works but it is very rough.
 

Attachments

• Return the leading comma in all cases, and always remove it...
Code:
Mid(IIF(SpecialSS, ", SS", "") & IIF(SpecialDT, ", DT", "") & IIF(SpecialSGT, ", SGT", ""), 3)
• Also, in boolean math the operation '= True' is called the Identity Function and it has no effect on the outcome.
• False = True? False.
• True = True? True.
 

Users who are viewing this thread

Back
Top Bottom