If, then display for option group results?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a form with a 2-option option group that returns a value of 1 or 2
for a field called "DDD Reportable". I have a report generated from data in
that form where I want to display the "DDD Reportable" field. How would I get
the report to display "yes" when the field is "1" and "no" when the field is
"2"?

Thanks a bunch.
David
 
Set a report control's ControlSource to:

=IIf([YourOptionGroup]=1,"Yes","No")

If you can also enter no value and wish to display this case on the report,
either use nested IIfs:

= IIf(IsNull([YourOptionGroup]),"No Selection
Made",IIf([YourOptionGroup]=1,"Yes","No"))

or create a simple function

Function MyOptionText(varSelection as Variant) As String
Select Case varSelection
Case 1
MyOptionText = "Yes"
Case 2
MyOptionText = "No"
Case Else
MyOptionText = "No selection made."
End Select
End Function

Then set the report control's ControlSource to:

=MyOptionText([YourOptionGroup])

Hope that helps.
Sprinks
 
Hi,

I have a form with a 2-option option group that returns a value of 1 or 2
for a field called "DDD Reportable". I have a report generated from data in
that form where I want to display the "DDD Reportable" field. How would I get
the report to display "yes" when the field is "1" and "no" when the field is
"2"?

Thanks a bunch.
David

Is [DDD Reportable] a field stored in a table, and included in the
report's record source?
In an unbound control in the report:
=IIf([DDD Reportable]=1, "Yes","No")
 
Hi,

You wrote;
Is [DDD Reportable] a field stored in a table, and included in the
report's record source?

The answer is yes.

I tried what you wrote. I inserted the following into the Control Source box:
=IIf([DDDReportable]=1,"Yes","No")

Yet when I try to run the report it only prints this in the DDDReportable
field:
# Error

Any idea why I might be getting that?

Thanks,
YYY

fredg said:
Hi,

I have a form with a 2-option option group that returns a value of 1 or 2
for a field called "DDD Reportable". I have a report generated from data in
that form where I want to display the "DDD Reportable" field. How would I get
the report to display "yes" when the field is "1" and "no" when the field is
"2"?

Thanks a bunch.
David

Is [DDD Reportable] a field stored in a table, and included in the
report's record source?
In an unbound control in the report:
=IIf([DDD Reportable]=1, "Yes","No")
 
Hi Fredg,

You know what? I figured it out. I had the DDDReportable tagged as a text
field when it needed to be a number. It works fine now.

Thanks for the help.
YYY

fredg said:
Hi,

I have a form with a 2-option option group that returns a value of 1 or 2
for a field called "DDD Reportable". I have a report generated from data in
that form where I want to display the "DDD Reportable" field. How would I get
the report to display "yes" when the field is "1" and "no" when the field is
"2"?

Thanks a bunch.
David

Is [DDD Reportable] a field stored in a table, and included in the
report's record source?
In an unbound control in the report:
=IIf([DDD Reportable]=1, "Yes","No")
 
Back
Top