Hi All, I posted this code last week and someone started me off in (I think) the right direction. But I’m still stuck. This is a hotspot button that adds a vacation request to the user’s calendar. I’m having a hard time getting the 8:00:00 AM time set. I’m confused by data types. Basically, I get stuck when I’m trying to set the string type variable (StartDateTime1) as the newly incremented date variable (StartDateTime2) so I can set the proper fields on the Calendar entry document.
Any help is very appreciated!!!
Sub Click(Source As Button)
Dim Session As New NotesSession
Dim Workspace As New NotesUIWorkspace
Dim TheDocument As NotesDocument
Dim db As notesDatabase
Dim UserName As String
Set UIDoc = Workspace.CurrentDocument
Set TheDocument = UIDoc.Document
Set db = New NotesDatabase("", "")
’ open mail database
db.openmail
Dim EndDate As String
Dim InitiatedDate As String
Dim InitiatedTime As String
Dim Subject As String
Dim Subject2 As String
Dim Descript As String
Dim StartDateTime1 As String
Dim EndDateTime1 As String
EndDate = UIDoc.FieldGetText("AbsenceToDate")
InitiatedDate = UIDoc.FieldGetText("AbsenceFromDate")
InitiatedTime = UIDoc.FieldGetText("EndTime44")
'Above EndTime44 is a field in the form that is defaulted to 8:00:00 AM
Subject = UiDoc.FieldGetText("AbsenceType")
Subject2 = UiDoc.FieldGetText("EmpSignature")
StartDateTime1 = UiDoc.FieldGetText("DateTimeStart")
EndDateTime1 = UiDoc.FieldGetText("DateTimeEnd")
'Above DateTimeStart and DateTimeEnd are fields on the form that take the time-only AbsenceFromDate and
'AbsenceToDate fields and convert them to a date and time field with 8:00:00 AM time stamp
'Below I adjust EndDate by one day so the loop works for a one-day vacation
'Also set StartDateTime2 so that I can adjust it by a day later. This is where I'm stuck. This doesn't seem right.
Set StartDate1 = New NotesDateTime (InitiatedDate)
Set EndDate2 = New NotesDateTime (EndDate)
Set StartDateTime2 = New NotesDateTime(StartDateTime1)
Call EndDate2.AdjustDay( 1 )
InitiatedDate = Cstr(StartDate1.DateOnly)
Enddate = Cstr(EndDate2.DateOnly)
'begin loop
Do While InitiatedDate <> EndDate
Dim CalendarEntry As New NotesDocument(db)
Dim rtitem As New NotesRichTextItem(CalendarEntry, "Body")
Call rtitem.AddNewline(1)
UserName = Session.CommonUserName
CalendarEntry.Form = "Appointment"
CalendarEntry.Principal = UserName
'use the full username instead of the common name, so the hide- whens in the appointment form work.
CalendarEntry.Chair = Session.UserName
CalendarEntry.ExcludeFromView = "D"
CalendarEntry.OrgTable = "CO"
CalendarEntry.SequenceNum = 1
CalendarEntry.Subject = Subject+ " - " + Subject2
CalendarEntry.~$PublicAccess="1"
CalendarEntry.~_ViewIcon = 10
'AppointmentType set here 4 is reminder
CalendarEntry.AppointmentType = "4"
CalendarEntry.StartDate = Cdat(InitiatedDate)
CalendarEntry.StartTime = Cdat(InitiatedTime)
CalendarEntry.StartDateTime = StartDateTime1
CalendarEntry.EndDate = Cdat(EndDate)
CalendarEntry.CalendarDateTime = StartDateTime1
Call StartDate1.AdjustDay( 1 )
Call StartDateTime2.AdjustDay( 1)
InitiatedDate = Cstr(StartDate1.DateOnly)
Enddate = Cstr(EndDate2.DateOnly)
'This is where I get stuck…
'The debugger tells me StartDateTime1 is a string - just like InitiatedDate! Why won’t it take the value?
StartDateTime1 = Cstr(StartDateTime2)
Call CalendarEntry.save(True, False)
Loop
Messagebox"The entry has been added to your calendar. Your calendar may need to be refreshed."
End Sub