Checkbox IIF statement URGENT HELP PLEASE!!!

H2wk1

New member
Local time
Today, 21:14
Joined
Apr 4, 2009
Messages
6
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.
 
I would need to see the whole function that this code is in, as I don't quite understand the context.
 
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
 
Last edited:
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. :-)
 

Users who are viewing this thread

Back
Top Bottom