Turning ticks into numerical values?

Bloodrayne

Newbie-rrific!
Local time
Today, 20:47
Joined
Oct 6, 2004
Messages
58
Hello all - third post in less than two days, I'm on a roll!

I was wondering if there's a way to get a numerical value out of a Yes/No field (say Yes = 1, No = 0) - for the purpose of reports (and more importantly the totals)

Cheers
 
You can evaluate it at runtime with something like the following in the query:

MyNewFld: iif([YesNoFld] = "Yes", 1, 0)

Would this work?
kh
 
=Sum(Abs(MyField))
=Sum(Iif(MyField,1,0))
=Sum(Iif(MyField=False,1,0))
 
Thanks for the answers...

But... umm... where do I put the suggested code?
 
You can put the code I posted in the underlying query, or you can put Rich's in the report footer.

kh
 
The criteria in the query?

I've added the below code:
Code:
"MyNewFld: iif[Flight_requested]"=("Yes",1,0)

Which doesn't work! Should I have altered the MyNewFld part?

I also get an error about the syntax (comma), could this be due to my other criteria?
 
Like this...
 

Attachments

  • query_example_01.gif
    query_example_01.gif
    4.5 KB · Views: 300
Ah - can't try it straight away, give me some time and I'll say if I've got it to work yet...

Here's hoping!
 
Decided to go for the Report Footer route, but am struggling with that too (darn it)

Code:
=Sum(Abs([Flight_Booked]))=Sum(IIf([Flight_Booked],1,0))=Sum(IIf([Flight_Booked]=False,1,0))

Which just results in an error (the field name is Flight Booked)
 
Hi

You only need =Sum(Abs([Flight_Booked]))

Assuming a tick in the box for booked flights


=Sum(IIf([Flight_Booked],1,0)) will also sum all ticked boxes
=Sum(IIf([Flight_Booked]=False,1,0)) will sum all non ticked boxes

Brian
 
Thanks - the report no longer says error, but now comes up with a zero as the value? No matter which bit of code I use...

Is there anything I should have selected that I could've missed?
 
Nothing obvious, are you sure you've selected any data, sorry about that:D

Can you post your db?
 
I deserved that :(

The question you should've asked is

"Did you type the field name in properly, you silly silly person?"

Doh...

Works now! :)
 
Don't worry about it, we've all been there, done that. Syntax errors are the most common and a b****r to find as we all read what we think we've typed. :(

Brian
 

Users who are viewing this thread

Back
Top Bottom