I'm using the following function and calling it with a command button:
Code:
Function AddOlContact()
On Error GoTo Error_Handler
Const olContactItem = 2
Dim olApp As Object
Dim Ctct As Object
Set olApp = CreateObject("Outlook.Application")
Set olContact = olApp.CreateItem(olContactItem)
With olContact
.FirstName = Me.FirstName.Value
.LastName = Me.LastName.Value
.JobTitle = Me.Title.Value
.CompanyName = Me.OriginatorName.Value
.BusinessAddressStreet = ""
.BusinessAddressCity = ""
.BusinessAddressState = ""
.BusinessAddressCountry = ""
.BusinessAddressPostalCode = ""
.BusinessTelephoneNumber = Me.BusinessPhone.Value
.BusinessFaxNumber = Me.Fax.Value
.Email1Address = "Me.Email.Value"
.MobileTelephoneNumber = Me.CellPhone.Value
.Display 'use .Display if you wish the user to see the contact pop-up
End With
Error_Handler_Exit:
On Error Resume Next
Set olContact = Nothing
Set olApp = Nothing
Exit Function
Error_Handler:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf & "Error Number: " & _
Err.Number & vbCrLf & "Error Source: AddOlContact" & vbCrLf & "Error Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Function
However if a field is blank I get an error msg saying access doesn't support it. Any thoughts how to get around the error in the even a field is blank?