C
CCripe
I want to create a button that opens an Outlook contact form and populates it
with data from the Access database. When I click the button on the form, it
looks like it's going to work and then I get this error: "Object doesn't
support this property or method." Below is my code. Any help is GREATLY
appreciated.
Private Sub Command105_Click()
On Error GoTo Err_Command105_Click
Dim ol As Outlook.Application
Set ol = CreateObject("Outlook.Application")
Dim ns As NameSpace
Set ns = ol.GetNamespace("Mapi")
Dim NewContact As ContactItem
ns.Logon , , True
Set NewContact = ol.CreateItem(olContactItem)
With NewContact
.First Name = Forms!frmProspect!sfrmContacts!FirstName
.Last Name = Forms!frmProspect!sfrmContacts!LastName
.BusinessPhone = Forms!frmProspect!sfrmContacts!DirectNumber
.MobilePhone = Forms!frmProspect!sfrmContacts!CellPhone
.EmailAddress = Forms!frmProspect!sfrmContacts!EmailAddress
End With
Screen.PreviousControl.SetFocus
DoCmd.FindNext
Exit_Command105_Click:
Exit Sub
Err_Command105_Click:
MsgBox Err.Description
Resume Exit_Command105_Click
End Sub
with data from the Access database. When I click the button on the form, it
looks like it's going to work and then I get this error: "Object doesn't
support this property or method." Below is my code. Any help is GREATLY
appreciated.
Private Sub Command105_Click()
On Error GoTo Err_Command105_Click
Dim ol As Outlook.Application
Set ol = CreateObject("Outlook.Application")
Dim ns As NameSpace
Set ns = ol.GetNamespace("Mapi")
Dim NewContact As ContactItem
ns.Logon , , True
Set NewContact = ol.CreateItem(olContactItem)
With NewContact
.First Name = Forms!frmProspect!sfrmContacts!FirstName
.Last Name = Forms!frmProspect!sfrmContacts!LastName
.BusinessPhone = Forms!frmProspect!sfrmContacts!DirectNumber
.MobilePhone = Forms!frmProspect!sfrmContacts!CellPhone
.EmailAddress = Forms!frmProspect!sfrmContacts!EmailAddress
End With
Screen.PreviousControl.SetFocus
DoCmd.FindNext
Exit_Command105_Click:
Exit Sub
Err_Command105_Click:
MsgBox Err.Description
Resume Exit_Command105_Click
End Sub