I think your syntax is wrong. iif should be IIF(<expresstion to evaluate>,<then expression>,<else expression>) and safedivide takes
safedivide(<numerator>,<denominator>,<if denom 0 return expression>). So you have
SafeDivide(IIF
(Year([HEADER_RR.ORIGONPLANDT])>= "2005",[LIBLEADERDETAIL_RR.HOMECNT]/DateDiff("d",HEADER_RR.ORIGONPLANDT],EndDate)*7,[LIBLEADERDETAIL_RR.HOMECNT]/YTDWEEKSVAR,0)
)
and you probably want
IIF((Year([HEADER_RR.ORIGONPLANDT])>= "2005"),
safedivide([LIBLEADETAIL_RR.HOMECNT],
DateDiff("d",[HEADER_RR.ORIGONPLANDT],EndDate)*7,
<your divide default>),
safedivide([LIBLEADERDETAIL_RR.HOMECNT],YTDWEEKSVAR,0))
In other words (pseudo code here):
if Year([HEADER_RR.ORIGONPLANDT])>= "2005") then
if DateDiff("d",[HEADER_RR.ORIGONPLANDT],EndDate)* 7 <> 0 then
([LIBLEADETAIL_RR.HOMECNT]/
DateDiff("d",[HEADER_RR.ORIGONPLANDT],EndDate)*7
else
<your divide default>)
end if
else
if YTDWEEKSVAR<>0 then([LIBLEADERDETAIL_RR.HOMECNT]/YTDWEEKSVAR
else
0
end if
end if
or something like that??