Samantha
still learning...
- Local time
- Today, 17:04
- Joined
- Jul 12, 2012
- Messages
- 180
I am using the on click event to add my Access Contact to outlook and I am finding some odd behavior. It seems that if the contact is missing information like the Fax number then it throws this error message up (error number-2147352571 Outlook cannot translate) I have found that it is a result of missing information. So I am assuming that I need some type of line entered in the code that states " if the value is null then leave the field blank" Since I am in the learning process, I figured it would be best to ask for some advice! Please and Thank you!
Samantha
Samantha
Code:
Private Sub cmdSaveToOutlook_Click()
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.First
.LastName = Me.Last
.JobTitle = Me.Job_Title
.CompanyName = Me.Company
.BusinessAddressStreet = Me.Address
.BusinessAddressCity = Me.City
.BusinessAddressState = Me.State
.BusinessAddressCountry = "USA"
.BusinessAddressPostalCode = Me.Zip_Postal_Code
.BusinessTelephoneNumber = Me.Phone
.BusinessFaxNumber = Me.Business_Fax
.Email1Address = Me.E_mail_address
.Email1DisplayName = Me.DisplayAs
.MobileTelephoneNumber = Me.Mobile_Phone
.Display 'use .Display if you wish the user to see the contact pop-up .Save to save
End With
Error_Handler_Exit:
On Error Resume Next
Set olContact = Nothing
Set olApp = Nothing
End
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 Sub