That's because you're putting a string (N/A) in some cases, and Sum won't
work on strings.
Try:
Sum(IIf([Type Of Day]="Personal" Or [Type Of Day]="Jury Duty" Or [Type of
Day]="Carryover",0,DateDiff("d",[OLP Begin Date],[OLP End Date])))
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Joanne" <(E-Mail Removed)> wrote in message
news:5D768884-86C4-4778-A7C2-(E-Mail Removed)...
> I'm so confused, I just feel like giving this whole thing up. But I'll
> try
> to explain. I have a subform in a form which is for totaling vacation
> time.
> In the subform each line represents one request for vacation time. The
> fields are as follows:
> Begin Date End Date Type of Day Total Days
>
> The "type of day" can be "personal", "vacation", "jury duty" or
> "carryover".
> The total days field has the following in it:
> =IIf([Type Of Day]="Personal" Or [Type Of Day]="Jury Duty" Or [Type of
> Day]="Carryover","N/A",DateDiff("d",[OLP Begin Date],[OLP End Date]))
>
> This works fine. But then I've put a calculated field into my query
> called
> "Total Vacation" with the same code. Then in my footer on the subform I
> put
> =Sum([TotalVacation]) and I get #error when I view the form. I'm so
> confused
> because 1. I don't understand why I'm getting the error and 2. I don't
> understand why I have to bind the field in the footer to a field in the
> query
> when it could just calculate right from the form, couldn't it? Couldn't
> it
> just add up all of the "total days" entries right in the form? This seems
> like cheating since it's not really doing a direct calculation. What if I
> changed the code in the form and forgot to change it in the query? Thanks
> for getting me unconfused about this.
>
>