Wildcard in IIf statement

  • Thread starter perryclisbee via AccessMonster.com
  • Start date
P

perryclisbee via AccessMonster.com

I did a query where I want to add on a certain amount of months to a date
depending on the contents of another field. Here is the statement I used:

SwitchDate: IIf([Active_SPA_summary_02d]![MODALITY]="*PD*",DateAdd("m",30,
[Active_SPA_summary_02d]![MaxOfFIRST_DIALYSIS]),DateAdd("m",33,
[Active_SPA_summary_02d]![MaxOfFIRST_DIALYSIS]))

Does this look right? I want to add 30 months to the original date
[MaxOfFIRST-DIALYSIS] if the MODALITY field has anything with the letters PD
in it. If it doesn't, I want to add 33 months to the original date. Will
the "*PD*" structure work accurately?

Thanks,

Perry
 
J

John Spencer

You don't use = with wild cards. You use LIKE

SwitchDate: IIf([Active_SPA_summary_02d]![MODALITY] LIKE "*PD*"
,DateAdd("m",30,[Active_SPA_summary_02d]![MaxOfFIRST_DIALYSIS])
,DateAdd("m",33,[Active_SPA_summary_02d]![MaxOfFIRST_DIALYSIS]))

OR you use the INSTR function
SwitchDate: IIF(INSTR(1,Active_SPA_Summary_02d.Modality,"PD",1)>0,
,DateAdd("m",30,[Active_SPA_summary_02d]![MaxOfFIRST_DIALYSIS])
,DateAdd("m",33,[Active_SPA_summary_02d]![MaxOfFIRST_DIALYSIS]))
 
G

Guest

TRy this --
SwitchDate: IIf([Active_SPA_summary_02d]![MODALITY] Like
"*PD*",DateAdd("m",30,
[Active_SPA_summary_02d]![MaxOfFIRST_DIALYSIS]),DateAdd("m",33,
[Active_SPA_summary_02d]![MaxOfFIRST_DIALYSIS]))
 

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

Top