Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a boolean field called [Hisp

Status
Not open for further replies.

Shrum

Programmer
May 17, 2002
122
US
I have a boolean field called [Hisp] that I want to do a expression on.

=iif([Hisp],"Hispanic","English")

For some reason this ALWAYS returns "Hispanic" regardless of the state of the field.

I tried things like:

[hisp].[text]="Yes"
[hisp].[text]="True"

...but nothing is working...it keeps coming back with "Hispanic".

How do I set up the expression to deal with boolean fields?

TIA

Sean Shrum
sean@shrum.net
sean_shrum@hotmail.com
 
Try the following...

=iif(Me![Hisp] = True,"Hispanic","English") Programming isn't a profession of choice.
It's a profession of calling...
"Hey Programmer, your application broke again!" [spin]

Robert L. Johnson III, A+, Network+, MCP
robert.l.johnson.iii@ssmb.com
 
Nope....that didn't work. When I run the report, I'm prompted for a "Me parameter value"

Thinking along the same lines I also tried calling the table by name:

=iff([main list]![Hisp] = True), "Hispanic", "English")
=iff([main list]![Hisp]), "Hispanic", "English")

These both failed as well.

This seems odd. The logic seems sound. Why isn't this working?

TIA

Sean Shrum
 
Hi Sean!

Is Hisp included in the recordset that the report is based on? If it isn't then you need to include for your expression to work.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Yes. The field is included.

If I just include the field in the report (no expression), the control displays "Yes" (if field is checked in the database) and "No" if not.

The Query that I'm basing on contains two tables. I'm using the "*" from each. Here is my SQL:

SELECT DONATIONS.*, [MAIN LIST].*
FROM DONATIONS INNER JOIN [MAIN LIST] ON DONATIONS.ID = [MAIN LIST].ID;

[Hisp] is contained in [Main List].

TIA

Sean Shrum
sean@shrum.net
sean_shrum@hotmail.com
 
Sean,
Have you tried just;
IIf(Me![hisp]="hispanic","hispanic","english")
Jim
 
That won't work.

The field is a true/false boolean field. By it's very nature that logic doesn't apply.

It *would* work if the field was a text field and the value I was looking for was "hispanic".

Nice try, but no go.

Sean Shrum
sean@shrum.net
sean_shrum@hotmail.com
 
Sean,
One more try. For the yes and no substitute -1 for false and 0 for true.
=iff([main list]![Hisp] = 0), "Hispanic", "English")
 
Good thought, but no go.

=iif([Main List]![Hisp]=0,"Hispanic","English")

...generated a entry prompt ([Main List]. Slightly mod'ed, this is what I have:

=iif([Hisp]=0,"Hispanic","English")

While this seems valid, when I run the report I get:

#error

For now, I just inserted a checkbox control. This functions but is not what I want (in the long run).

Keep the ideas coming...this problem is driving me nuts.

Sean Shrum
sean@shrum.net
sean_shrum@hotmail.com
 
Am I just missing something?

I just set up a dummy table with a boolean (true/false) field named HISP; then set up a report based on that table (same concept would work if querying the table); on report, I've listed the table records in the detail section and created an unbound text box in the detail section with the control source set to:
=IIf([Hisp]=True,"Hispanic","English")

When I run the report, if the Hisp field is checked, my unbound text box displays "Hispanic"; otherwise, it displays "English".

I did the same thing again with the HISP field set up as a yes/no text field (still boolean) so that it displays YES or NO rather than a check box. Unbound control source changed to:
=IIf([Hisp]=Yes,"Hispanic","English")
And it still worked.

So what's up?

-hmm
 
BTW, I wasn't trying to sound rude or condescending; I honestly am under the assumption that I'm missing something somewhere...

If I haven't missed something, and what I did works for you, great! Otherwise, clue me in. :)
 
I totally agree. These *should* both work:

=IIf([Hisp]=True,"Hispanic","English")
=IIf([Hisp],"Hispanic","English")

I think there is a bug here but I just can't figure it out.

I'm running SR-1 but will d/l SR-2b in the hopes that maybe this is addressed there perhaps.

The client is happy with my idea of using the checkbox field (which is working) instead of "Hispanic"/"English".

I'll post again later if I find the source of the problem.

Sean Shrum

Thanks for all the help.
 
I agree that it should work. I'm wondering if the report/query may be corrupted.

Try creating a new query and put the expression in the query and see what happens.

If that doesn't work, try creating a new database and linking the necessary tables. Then try the above query solution again.

If either of the above queries work, create a new report and base it on the above query.

I've had some weird things happen with reports in the past were they just flake and one small item will refuse to work properly.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top