I have the following code code for calculating vacation days.. It is failing on ONLY the Forall loop, giving the error, Object Variable not set. I looked through it and thought it was holiday not declared, but when I add Dim holiday as NotesDateTime, the code won't save because it says "alias variable was previously declared'. Designer help says "You cannot declare a reference variable outside a ForAll statement. ". When I rem out the Forall loop, the code runs but it doesn't calculate the days taken.
I can paste the rest of the code in if you want, but I'm only pasting in here the part that I know is failing and the declaration that applies. Again there is no Dim for holiday, but when I put it in the code won't save, saying Data not saved due to script error, and the error is: FORALL alias variable was previously declared: HOLIDAY
It's not DIM'd in this object or any other. The variable TotalDays at the end is what I need.
Dim counter As Integer
Dim flag As Integer
Dim days As Integer
Dim duration() As String
Dim TotalDays As Integer
Dim count As Integer
Dim hookdoc As NotesDocument
Dim startdate As NotesDateTime
Dim enddate As NotesDateTime
Do While startdate.TimeDifference(enddate) <= 0 'Once we check the end date we're done!!
flag = 0
days = Weekday(startdate.LSLocalTime)
If days <> 1 And days <> 7 Then ' 'check for holidays
Forall holiday In hookdoc.AllHolidays
If Cdat(holiday) = startdate.LSLocalTime Then flag=1
If flag =0 Then
Redim Preserve duration(0 To counter)
duration(counter) = startdate.LSLocalTime
counter = counter +1
doc.TotalDays = counter
doc.Duration = duration