View Full Version : Checkbox IIF statement URGENT HELP PLEASE!!!


H2wk1
04-04-2009, 12:32 AM
Hi...

I am currently trying to read the checkbox value from a field in a table and do a calculation using the data. If the checkbox is checked then i charge a weekend rate, if it isn;t checked i charge a weekday rate.

IIf(Invoice.HiredOnWeekend=TRUE,SUM(DATEDIFF("d",Invoice.HiringDate,Invoice.ReturnDate)*Equipment. EquipmentPriceWeek),SUM(DATEDIFF("d",Invoice.HiringDate,Invoice.ReturnDate)*Equipment. EquipmentPriceWeek))

I have tried various values for what the checkbox should read but no luck yet. (true,false,0,1,-1, and just the coloum name)

Any help is greatly appreciated.

Uncle Gizmo
04-04-2009, 01:25 AM
I would need to see the whole function that this code is in, as I don't quite understand the context.

raskew
04-04-2009, 03:13 AM
Hi -

For starters, the Iif() statement takes this format:
Iif(Expression, True, False)

The example you provided gives identical values for both the True and False options:
SUM(DATEDIFF("d",Invoice.HiringDate,Invoice.ReturnDate)*Equipment. EquipmentPriceWeek),
SUM(DATEDIFF("d",Invoice.HiringDate,Invoice.ReturnDate)*Equipment. EquipmentPriceWeek))

That may not be the whole problem. Waiting to see the complete code. Added: ...and an explanation of what happens, e.g. error message, etc..

Bob

H2wk1
04-04-2009, 03:39 AM
Thanks guys. I was being stupid. Must have been the exhaustion. Eveything was right except that the two expressions were exactly the same. Thanks raskew.

All appreciate works like a dream now. :-)