nightflight
Registered User.
- Local time
- Today, 04:17
- Joined
- Mar 15, 2011
- Messages
- 24
[SOLVED] Nested IIf( with DMax and DateAdd not working correctly
As the control source of txt_expdate I have the following
=IIf(([txt_coursedate]>DMax("certexpires","qry_personcert")),
DateAdd("m",36,[txt_coursedate]),
IIf(([txt_coursedate] Between DMax("certexpires","qry_personcert") And DateAdd("m",-3,DMax("certexpires","qry_personcert"))),
DateAdd("m",36,DMax("certexpires","qry_personcert")),
IIf([txt_coursedate]<(DateAdd("m",-3,DMax("certexpires","qry_personcert"))),
DateAdd("m",39,[txt_coursedate]),[txt_coursedate])))
so for example, with certexpires : 21/07/2012 and txt_coursedate: 22/06/2012
txt_expdate should be 21/07/2015, not 22/06/2015 which it's giving me.
checking with txt_coursedate, 21/01/2012 gives 21/04/2015 as it should and with 22/07/2012 gives 22/07/2015 as it should, so the issue seems to be with the Between..And.. statement?
Can anyone point me in the right direction?
Thanks
As the control source of txt_expdate I have the following
=IIf(([txt_coursedate]>DMax("certexpires","qry_personcert")),
DateAdd("m",36,[txt_coursedate]),
IIf(([txt_coursedate] Between DMax("certexpires","qry_personcert") And DateAdd("m",-3,DMax("certexpires","qry_personcert"))),
DateAdd("m",36,DMax("certexpires","qry_personcert")),
IIf([txt_coursedate]<(DateAdd("m",-3,DMax("certexpires","qry_personcert"))),
DateAdd("m",39,[txt_coursedate]),[txt_coursedate])))
so for example, with certexpires : 21/07/2012 and txt_coursedate: 22/06/2012
txt_expdate should be 21/07/2015, not 22/06/2015 which it's giving me.
checking with txt_coursedate, 21/01/2012 gives 21/04/2015 as it should and with 22/07/2012 gives 22/07/2015 as it should, so the issue seems to be with the Between..And.. statement?
Can anyone point me in the right direction?
Thanks
Last edited: