I have a form which i want to use to create appointments in Outlook. I have the VBA code to do this but for some reason the code doesnt pick up the data from the form any suggestions what i have done wrong?
this is the code i am using
Sub CreateAppointment1()
Dim dtDue As String
Dim tmDue As String
dtDue = DueDate
tmDue = DueTime
On Error GoTo AddAppt_Err
' Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
' Exit the procedure if appointment has been added to Outlook.
If AddedToOutlook = True Then
MsgBox "This Case is already in Monitoring Mode"
Exit Sub
' Add a new appointment.
Else
Dim outobj As Outlook.Application
Dim outappt As Outlook.AppointmentItem
Dim APPDue As String
APPDue = dtDue & " " & tmDue & ":00"
Set outobj = CreateObject("Outlook.Application")
Set outappt = outobj.CreateItem(olAppointmentItem)
With outappt
.Start = Now() + 1
''''''''''''''''''APPDue
.Duration = "5"
.Subject = "Monitoring someone at " & Site
If Not IsNull(Descriptions) Then .Body = Description
If Not IsNull(Site) Then .Location = Site
.Save
End With
End If
' Release the Outlook object variable.
Set outobj = Nothing
' Set the AddedToOutlook flag, save the record, display a message.
AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
Exit Sub
AddAppt_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
Bookmarks