Custom field in a query

ZBKAI189

Registered User.
Local time
Yesterday, 17:20
Joined
Aug 4, 2009
Messages
26
Can a custom field in a query return 'A' if condition 1 is met and 'B' if condition 1 isn't met? If title="supervisor" then run equation 'x'... if title does not ="supervisor" then do not run equation 'x'.

Make sense?
 
Sure; try an IIf() function:

IIf(title="supervisor", "A", "B")
 
Ok... sounds easy enough =/

Right now I have "DUE_MXG: DateAdd("m",-1,[proj_eval_close_date])"

But I only want that equation is title=supervisor

If title does not=supervisor then I need it to display N/A or something along those lines.

Idea?
 
You'd replace "A" with the DateAdd equation, and "B" with "N/A".
 
I've got:

DUE_MXG: IIf([LOCAL].[GRADE]="MSG" Or "SMS" Or "CMS",DateAdd("m",-1,[proj_eval_close_date]),"N/A")

But when I run the query I get the dateadd for all records... even if the requirement isn't met (local.grade="msg" or "sms" or "cms")
 
That's different than your original request, but in any case you have to repeat the field:

IIf([LOCAL].[GRADE]="MSG" Or [LOCAL].[GRADE]="SMS" Or [LOCAL].[GRADE]="CMS",...
 
Yippee! Glad we got it sorted out.
 
Oh wait... almost. It returns the correct information... but any idea why I can't get the dates to display as medium date? I've got all formats set to medium... but it displays as short.
 
I would generally format it in the form or report the user will see, but that might be screwed up here because of the mix of date and text values. You may need to wrap the DateAdd() function in the Format() function.
 

Users who are viewing this thread

Back
Top Bottom