I have this code for assigning tasks. When I run the code, I get the "Invalid use of null" error message. I looked at all the fields on the form and subform and nothing is null. Why am I getting this error message. Please help.
Dim OutlookApp As New Outlook.Application
Dim OutlookTask As Outlook.TaskItem
Dim AssignedTo As Outlook.Recipient
Dim Email As String
Dim olNS As Outlook.NameSpace
Set OutlookApp = CreateObject("Outlook.Application")
Set olNS = OutlookApp.GetNamespace("MAPI")
olNS.Logon
Set OutlookTask = OutlookApp.CreateItem(olTaskItem)
Email = Replace(Forms![frm_CARReview]![tbl_CARLDReview subform1]!cbo_AssignedTo.Column(1), " ", ".") & "@testamericainc.com"
OutlookTask.Assign
Set AssignedTo = OutlookTask.Recipients.Add(Email)
OutlookTask.Subject = "You have been assigned a task. See CAR Number " & Forms![frm_CARReview]![txt_CARID]
OutlookTask.Body = Forms![frm_CARReview]![tbl_CARLDReview subform1]!txt_ReviewNotes
OutlookTask.DueDate = Forms![frm_CARReview]![tbl_CARLDReview subform1]!txt_PlannedCompletion
OutlookTask.Importance = (olImportanceHigh)
OutlookTask.ReminderSet = True
OutlookTask.Save
OutlookTask.Send
OutlookTask.Display
OutlookApp.Quit
Set OutlookTask = Nothing
Dim OutlookApp As New Outlook.Application
Dim OutlookTask As Outlook.TaskItem
Dim AssignedTo As Outlook.Recipient
Dim Email As String
Dim olNS As Outlook.NameSpace
Set OutlookApp = CreateObject("Outlook.Application")
Set olNS = OutlookApp.GetNamespace("MAPI")
olNS.Logon
Set OutlookTask = OutlookApp.CreateItem(olTaskItem)
Email = Replace(Forms![frm_CARReview]![tbl_CARLDReview subform1]!cbo_AssignedTo.Column(1), " ", ".") & "@testamericainc.com"
OutlookTask.Assign
Set AssignedTo = OutlookTask.Recipients.Add(Email)
OutlookTask.Subject = "You have been assigned a task. See CAR Number " & Forms![frm_CARReview]![txt_CARID]
OutlookTask.Body = Forms![frm_CARReview]![tbl_CARLDReview subform1]!txt_ReviewNotes
OutlookTask.DueDate = Forms![frm_CARReview]![tbl_CARLDReview subform1]!txt_PlannedCompletion
OutlookTask.Importance = (olImportanceHigh)
OutlookTask.ReminderSet = True
OutlookTask.Save
OutlookTask.Send
OutlookTask.Display
OutlookApp.Quit
Set OutlookTask = Nothing