4/29/2010

Setting Dual Deadlines for Expire Dates

I just had a customer ask about another Expire Date scenario. They don't have sliding Expire Dates but they have two deadlines. All permits expire in six months if construction is not started, but once started they have two years to finish. To keep track of this scenario you can use the same tutorials that go with the sliding Expire Dates with just some minor modifications to the initial script. Basically you set up the initial six month expiration deadline by setting Expire Days to 183 for each permit type in Maintenance. Then you only need a script to make the switch to the two year deadline. This is done with a script that uses "Building" as the Module, "Building" as the Screen, and "Close" as the Action.

myanswer = 0
mycode = id_code
select max(last_insp) from detail1;
where detail1.id_code = mycode into array mydate
mylast = mydate(1)
if not empty(mylast) and mylast > (cert_date)
myanswer = messagebox("New expire should be "+dtoc(cert_date +730);
+chr(13)+"Do you want to fix it?",68,"New Expiration Needed")
endif
use in detail1
if myanswer = 6
proceedwithclose = .F.
replace exp_date with cert_date+730
buildscreen.isediting = .T.
buildscreen.refresh
endif