Question

Locked

Access Error 91

By fabio.fantuzzi ·
I'm not expert with VBA and I'm trying to create a piece of code that creates a new Outlook contact using data inserted in an Access form. Both Access and Outlook are version 2002. When I activate the procedure, built basing on an example found just in this forum, I get Access Error 91. Follows the code I'm using.
I apologize for the lack of professionality, but it's not my job.

Private Sub Comando155_Click()
'Created by Helen Feddema 8-25-2000
'Last modified 8-26-2000
On Error GoTo ErrorHandler
Dim Response
Dim itms As Outlook.Items
Dim itm As Outlook.ContactItem
Response = MsgBox("Dim itms e itm ok")
Dim strTitle As String
Dim strFirstName As String
Dim strMiddleName As String
Dim strLastName As String
Dim strSuffix As String
Dim strJobTitle As String
Dim strCompany As String
Dim strLastNameFirst As String
Dim strBusinessStreet As String
Dim strBusinessStreet2 As String
Dim strBusinessCity As String
Dim strBusinessState As String
Dim strBusinessPostalCode As String
Dim strBusinessCountry As String
Dim strBusinessPhone As String
Dim strBusinessFax As String
Dim strHomeStreet As String
Dim strHomeStreet2 As String
Dim strHomeCity As String
Dim strHomeState As String
Dim strHomePostalCode As String
Dim strHomeCountry As String
Dim strHomePhone As String
Dim strHomeFax As String
Dim strOtherStreet As String
Dim strOtherStreet2 As String
Dim strOtherCity As String
Dim strOtherState As String
Dim strOtherPostalCode As String
Dim strOtherCountry As String
Dim strOtherPhone As String
Dim strOtherFax As String
Dim strEMailAddress As String
Dim strEMailAddress2 As String
Dim strContactID As String
Dim lngCount As Long
Dim strMessage As String
Dim lngResult As Long
Dim strContactForm As String
Dim dteLastVisit As Date
Dim intNoChildren As Integer
Dim strCustomerType As String
Dim strCategory As String
Dim varReturn As Variant
Dim lngPosition As Long




' Set itms = pfld.Items
'Create a contact item
Set itm = itms.Add(strContactForm)

'Write values from variables to fields in the new Contact item
With itm
'Standard Contact fields
.CustomerID = strContactID
.Title = strTitle
.MiddleName = strMiddleName
.LastName = strLastName
.Suffix = strSuffix
.JobTitle = strJobTitle
.BusinessAddressCountry = strBusinessCountry
.HomeAddressStreet = strHomeStreet
.HomeAddressCity = strHomeCity
.HomeAddressState = strHomeState
.HomeAddressPostalCode = strHomePostalCode
.HomeAddressCountry = strHomeCountry
.HomeTelephoneNumber = strHomePhone
.HomeFaxNumber = strHomeFax
.OtherAddressStreet = strOtherStreet
.OtherAddressCity = strOtherCity
.OtherAddressState = strOtherState
.OtherAddressPostalCode = strOtherPostalCode
.OtherAddressCountry = strOtherCountry
.OtherTelephoneNumber = strOtherPhone
.OtherFaxNumber = strOtherFax
.Email2Address = strEMailAddress2
.Categories = strCategory

.FirstName = Nome
.CompanyName = Nome
.BusinessAddressStreet = Legale_Indirizzo
.BusinessAddressCity = Legale_Citta
.BusinessAddressState = Legale_Prov
.BusinessAddressPostalCode = Legale_Cap
.BusinessTelephoneNumber = Tel
.BusinessFaxNumber = Fax
.Email1Address = E_mail
'Close and save new contact item
.Close (olSave)
Response = MsgBox("close ok")

DoCmd.RunCommand acCmdSaveRecord


End With

MsgBox "All Contacts exported!"

ErrorHandlerExit:
Exit Sub

ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End Sub

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Software Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums