Hello community
I am working on a vba code ( i am not a vba specialist) to set a task in outlook, i have only 2 fields a textbox and a calendar-box, assuming that I hit OK and I forgot an empty field I got a run-time error 94 related to .DueDate, can someone fix this? Or improve the code with the handling error code? I need this also to prevent that Users access Debug. This is the code and Thank you so much for the help:
Private Sub Command10_Click()
Dim OutlookApp As OutLook.Application
Dim outLookTask As OutLook.TaskItem
Set OutlookApp = CreateObject("outlook.application")
Set outLookTask = OutlookApp.CreateItem(olTaskItem)
With outLookTask
.Subject = "Reminder for Task: " & Me.TaskName
.Body = "This is a Task-Reminder from RinkuFM. Task name: " & Me.TaskName & " is due on " & Me.DueDate
.ReminderSet = True
.DueDate = Me.DueDate ' here i got the error
.ReminderTime = Me.DueDate - 7 & " 9:00 AM"
.Save
End With
MsgBox " Task has been set in Outlook successfully. You will be noticed in 7 days at 9:00 AM!", vbInformation, "Set Task Confirm"
End
End Sub
I am working on a vba code ( i am not a vba specialist) to set a task in outlook, i have only 2 fields a textbox and a calendar-box, assuming that I hit OK and I forgot an empty field I got a run-time error 94 related to .DueDate, can someone fix this? Or improve the code with the handling error code? I need this also to prevent that Users access Debug. This is the code and Thank you so much for the help:
Private Sub Command10_Click()
Dim OutlookApp As OutLook.Application
Dim outLookTask As OutLook.TaskItem
Set OutlookApp = CreateObject("outlook.application")
Set outLookTask = OutlookApp.CreateItem(olTaskItem)
With outLookTask
.Subject = "Reminder for Task: " & Me.TaskName
.Body = "This is a Task-Reminder from RinkuFM. Task name: " & Me.TaskName & " is due on " & Me.DueDate
.ReminderSet = True
.DueDate = Me.DueDate ' here i got the error
.ReminderTime = Me.DueDate - 7 & " 9:00 AM"
.Save
End With
MsgBox " Task has been set in Outlook successfully. You will be noticed in 7 days at 9:00 AM!", vbInformation, "Set Task Confirm"
End
End Sub