Replace two checkboxes values with one label

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi

I got two checkboxes. On my report I want to read the checkboxes and
depending on the value write something in a label.

Like this:

O O = None
X O = E
O X = S
X X = Both

I'm guessing that I write something in On Format event of the Detail
section.

// Peter
 
You can do this without any code.

Place a text box on your report, and give it these properties:
Name txtResult
Control Source =[CheckBox1] + 2 * [CheckBox2]
Format General Number
Visible No

Now add another text box to show the result, and set its ContorlSource to:
=Switch([txtResult]=-3, "Both", [txtResult]=-2, "S", [txtResult]=-1, "E",
[txtResult]=0, "None", True, "Unknown")

This works on the basis that True is -1. The Control Source of txtResult
will have a value from -3 to 0 depending on the values of the check boxes.
The Control Source of the 2nd text box uses the Switch() function to give
the desired result.
 
Thanks! That was just what I needed!

// Peter


Allen Browne said:
You can do this without any code.

Place a text box on your report, and give it these properties:
Name txtResult
Control Source =[CheckBox1] + 2 * [CheckBox2]
Format General Number
Visible No

Now add another text box to show the result, and set its ContorlSource to:
=Switch([txtResult]=-3, "Both", [txtResult]=-2, "S", [txtResult]=-1, "E",
[txtResult]=0, "None", True, "Unknown")

This works on the basis that True is -1. The Control Source of txtResult
will have a value from -3 to 0 depending on the values of the check boxes.
The Control Source of the 2nd text box uses the Switch() function to give
the desired result.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.


Peter said:
Hi

I got two checkboxes. On my report I want to read the checkboxes and
depending on the value write something in a label.

Like this:

O O = None
X O = E
O X = S
X X = Both

I'm guessing that I write something in On Format event of the Detail
section.

// Peter
 
Back
Top