Hi,
I have a database that we use booking rooms and several other things and I want to create a button to copy calendar entries across to a person’s mail file calendar.
I’ve written some code and it seems to create the event properly, with the right dates and times, but when I save the event, it gets saved with the current date and time.
I guess there’s a field that’s being missed or not being re-calculated… can someone have a look at my code please and let me know what is going on.
Thanks.
Gavin.
My Code is below.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim Doc As NotesDocument
Dim db As New NotesDatabase( "", "" )
Dim UIDoc As NotesUIDocument
Dim CurDoc As NotesDocument
Dim TXTTitle As String
Dim TXTGroup As String
Dim TXTSubject As String
Dim TXTDate As String
Dim TXTLocation As String
'Need to Open the Mail Database Before we can do anything with the Calendar...
Dim MailDB As New NotesDatabase( "", "" )
Call MailDB.OpenMail
Dim UIW As New NotesUIWorkspace
Call UIW.OpenDatabase( MailDB.server,MailDB.filepath,"($Calendar)")
Set CurDoc = ws.CurrentDocument.Document
TXTDate = CurDoc.GetItemValue("DTEDate")(0)
sd = TXTDate
ed = TXTDate
TXTSTime = CurDoc.GetItemValue("KEYStartTime")(0)
TXTFTime = CurDoc.GetItemValue("KEYFinishTime")(0)
st = TXTSTime
et = TXTFTime
TXTLocation = CurDoc.GetItemValue("KEYLocation")(0)
TXTTitle = CurDoc.GetItemValue("TXTTitle")(0)
TXTGroup = CurDoc.GetItemValue("KEYGroup")(0)
If Trim$(TXTTitle) = "" Then TXTSubject = TXTGroup Else TXTSubject = TXTTitle
Set db = session.CurrentDatabase
Set doc = MailDB.CreateDocument
doc.form = "Appointment"
doc.appointmenttype = "3"
doc.Subject = TXTSubject
doc.location = TXTLocation
doc.ExcludeFromView = "D"
doc.StartDate = sd
Set UIDoc = ws.EditDocument(True,doc)
Call uidoc.FieldSetText("EndDate", ed)
Call uidoc.FieldSetText("StartDate", sd)
Call uidoc.FieldSetText("StartTime", Cstr(st))
Call uidoc.FieldSetText("EndTime", Cstr(et))
Call uidoc.Refresh
End Sub