IIf statement

C

clueless

I am trying to write an IIf statement with the following info. If the
[StatusOfAppointment]="OnTime" and the [DriverTime] is greater than 2 hours
then "Detention" and then if the [StatusOfAppointment]="Early" then need to
use [DepartureTime]- [AppointmentTime] and if this is greater than 2 hours
"Detention",Null. I'm not sure how to put greater than 2 hours in the
statement. Any help would be greatly appreciated. Thank you in advance!
 
J

Jeff Boyce

Consider approaching this in steps, rather than all at once.

(the following assumes all these fieldnames are collected together into one
query ... or one table)

In a query, you could add a new field that was the difference between
[DepartureTime] and [AppointmentTime]. From your description, if this
difference is 2 hours or less, you don't care about teh record. If this is
true, you could add ">2" in the Selection Criterion area under your new
difference field (this assumes you measure in hours -- if not, format it
until you have hours).

Then it sounds like you only care when the [StatusOfAppointment] = "Early"
.... add that as a selection criterion.

I don't understand about [DriverTime], 2 hours and "Detention".

A selection criterion for [StatusOfAppointment] would be "OnTime".

Does that get you closer (and without having to puzzle out the IIF()
statement?)

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
K

KARL DEWEY

If your data is stored in hours then --
[DriverTime] > 2

If it is in minutes then --
[DriverTime] > 120

Otherwise use criteria appropriate to the data.
 

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

Similar Threads


Top