Some advise on this code, please

HiI found this code on forum, it works quite well…however, it appears that one has to manually enter the holidays…how would/could I incorporate a lookup to a view with all the holidays and it would automatically deduct the day if chosen?

Many thanks.

Coll

Here is the code:

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIdocument

Set uidoc=ws.currentDocument

Dim doc As NotesDocument

Set doc=uidoc.document



Const Saturday = 7

Const Sunday = 1

’ must have valid dates…

If doc.StartDate(0)="" Or doc.EndDate(0)="" Then 

	Exit Sub

End If



Dim count As Integer 

count = 0 ' half days



Dim dtVacationDayStart As New NotesDateTime(doc.startdate(0) )

Dim dtVacationDayEnd As New NotesDateTime(doc.enddate(0) )

'Determine if the user has requested an end date before the start date

If dtVacationDayStart.TimeDifference(dtVacationDayEnd ) > 0 Then

	Messagebox "you can't do that"

	Exit Sub 

Else

	Dim strVacationDate As String

	strVacationDate=dtVacationDayStart.DateOnly

	Dim dtVacationDay As New NotesDateTime(strVacationDate )

	Dim vacationdays As Integer

	Dim itemHolidays As NotesItem

	Set itemHolidays=doc.GetFirstItem("Holidays")

	Dim w As Integer 

	While Not (dtVacationDay.dateOnly >dtVacationDayEnd.DateOnly)

		If Not (Weekday(dtVacationDay.DateOnly)=Saturday Or Weekday(dtVacationDay.DateOnly)=Sunday) Then

			If Not(ItemHolidays.Contains(dtVacationDay)) Then

				count=count+2

			End If

		End If

		Call dtVacationDay.AdjustDay(1)

	Wend

’ adjust for half days…

	If doc.HalfDay(0) <> "" Then count = count - 1

	If doc.EndHalf(0) <> "" Then count = count - 1

	doc.TotalDays2 = count / 2 ' display result

	

End If

Call uidoc.Refresh

Subject: Some advise on this code, please.

Hmh… You could do a dbcolumn-lookup on a view with the holidays, and then loop through the selected range of dates, comparing every one of those dates with the returned list of holidays?

Would that do it?

Subject: Some advise this code, please.

yip, that sounds good…am not too fast with script…what would the equivalent be with @DBColumn…in LS?Thanks.

Subject: RE: Some advise this code, please.

You could use NotesDatabase FTSearchor NotesView FTSearch for this.

Easiest way to do it (for me) would be

to use Lotusscript Evaluate-method which

takes the Formula script as a parameter and runs it.

variable = Evaluate(“@DBLookup()”,doc)

Subject: Some advise this code, please

Hi

Thanks for the help,have tried this but giving me an error…what am I doing wrong?

Thank…

itemHolidays = session.Evaluate(“@DbLookup( “” : “” ; “” : “” ; “PublicHoliday” ; PubHol ; 1 )”, doc )

Subject: RE: Some advise this code, please

I’d suggest using Dbcolumn, but you can do it with dblookup also.

session.Evaluate(“@DBLookup(”“”“;”“”“:”“Database_File_name.nsf”“;”“Column name”";Search_argument;<Col_number>;)

In a hurry, sorry =)

Subject: RE: Some advise this code, please

@businessdays