Link to home
Start Free TrialLog in
Avatar of ghettocounselor
ghettocounselorFlag for United States of America

asked on

isnull inside of an iff statement MS Access

I'm having some trouble working out using the isnull within an if statement (MS Access 2003).

Things looks roughly like this -
MEDMRKUP - MEDMIN - IVMRKUP - IVMIN: IIf([GEN_DISP_UNIT]="DPU",[MED_PVAR1_DPU],[MED_PVAR1_DPD])+".....
the [MED_PVAR1_DPU] and [MED_PVAR1_DPD] might be null.
ASKER CERTIFIED SOLUTION
Avatar of Nick67
Nick67
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ghettocounselor

ASKER

Decided on this tactic:
  = UCase([LastName]) & ', ' & [FirstName] & ' ' & [Initial] & '. (' & [Title] & ')'

This shows as "DOE, John A. (Dr)". This is nice unless there is no middle initial or no title: "DOE, John . ()". If needed, Null values can be converted using Nz(). For example, display "nmi" for "no middle initial" or "?" for missing title:

        ... & Nz([Initial], 'nmi')
from link in selected resolution.

seems to be working as expected:
MEDMRKUP - MEDMIN - IVMRKUP - IVMIN: IIf([GEN_DISP_UNIT]="DPU",Nz([MED_PVAR1_DPU],'ndpu'),Nz([MED_PVAR1_DPD],'ndpd'))+" ....
 = UCase([LastName]) & ', ' & [FirstName] & ' ' & [Initial] & '. (' & [Title] & ')'
That looks like a ControlSource for a textbox on a form.
That's a place where @Harfang's nice little trick will work
 = UCase([LastName]) & ', ' & [FirstName] + ' ' & [Initial] & '. ' + (' & [Title] & ')'
As a ControlSource for a textbox, this will collapse to "DOE, John"  when the initial and title are null

MEDMRKUP - MEDMIN - IVMRKUP - IVMIN: IIf([GEN_DISP_UNIT]="DPU",Nz([MED_PVAR1_DPU],'ndpu'),Nz([MED_PVAR1_DPD],'ndpd'))+" ....
This looks like it's from a query, and that's pretty much the only way to do it.