R
Robgould
Guest
Hello,
I have some code to add a contact to outlook from my database. It works well as long as outlook is running. I outlook is closed it does not add, but after I start outlook and click my button again, it adds twice. I am not quite sure what is happening. Any suggestions would be apppreciated. Thanks.
Here is the code:
I have some code to add a contact to outlook from my database. It works well as long as outlook is running. I outlook is closed it does not add, but after I start outlook and click my button again, it adds twice. I am not quite sure what is happening. Any suggestions would be apppreciated. Thanks.
Here is the code:
Code:
Private Sub Command261_Click()
Dim olApp As Outlook.Application
Dim olnamespace As Outlook.NameSpace
Dim objcontact As Outlook.ContactItem
Set olApp = New Outlook.Application
Set olnamespace = olApp.GetNamespace("MAPI")
Set objcontact = olApp.CreateItem(olContactItem)
With objcontact
.LastName = Me.LastName
.Save
End With
Set objcontact = Nothing
Set objOutlook = Nothing
End Sub