Help in Coding please.

P

pbalmanno

My problem is the field is a yes/no which the check mark probably is
converted to binary. I want a text box whoose control source will determine
what text will appear based on a field's content (if the field is checked
yes). I've got this formula worked out to this point (below) but I get the
opposite result then expected IIf([FIELD2]=0, "TEXT2". When I switch it
around to IIf([FIELD2]=1 I don't get the expected result either.

=IIf([FIELD1]="TEXT1", "TEXT1", IIf([FIELD2]={yes/no field}(? which for
yes -1,0,1), "TEXT2","TEXT3")

Thanks,
 
F

fredg

My problem is the field is a yes/no which the check mark probably is
converted to binary. I want a text box whoose control source will determine
what text will appear based on a field's content (if the field is checked
yes). I've got this formula worked out to this point (below) but I get the
opposite result then expected IIf([FIELD2]=0, "TEXT2". When I switch it
around to IIf([FIELD2]=1 I don't get the expected result either.

=IIf([FIELD1]="TEXT1", "TEXT1", IIf([FIELD2]={yes/no field}(? which for
yes -1,0,1), "TEXT2","TEXT3")

Thanks,

A check box field (datatype Yes/No) will store either -1 (if checked)
or 0 (if not checked).

That's all you need store in the table.
On a report, to display text, all you need do is use an unbound text
control.
You can then either ...
set it's control source to:
=IIf([CheckField] = -1,"Checked Text Here","Not Checked Text Here.")

or...
Set the control's Control Source to the [CheckField].
Then set the control's Format property to:

;"Checked Text Here";"Not Checked Text Here.";

Either method will work.
 
S

Steve Sanford

And another way....

If the field in the table is a datatype of "Yes/No", then you can use the
predefined constants "TRUE" and "FALSE" instead of 0 (zero) and -1.


=IIf([FIELD1]="TEXT1", "TEXT1", IIf([FIELD2]= TRUE, "TEXT2","TEXT3")


Makes it easier to read IMO.....

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top