On Fri, 25 Jan 2013 20:10:51 +1100, The Frog
<
Mr.frog...@googlemail.com> wrote:
>On Thu, 24 Jan 2013 21:03:15 -0700, PW
><emailad...@ifIremember.com> wrote:
>> I figured it out! Wow! :-)
>
>And how did you do it?
Like this! I need to also search for the first name. More fun with
Access's syntax ;-)
Dim olApp As New Outlook.Application
Dim olContact As Outlook.ContactItem
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim strFirstName As String
Dim strLastName As String
Dim blnContinue As Boolean
Dim varReturnVal As Variant
strFirstName = Me.txtFirstName
strLastName = Me.txtLastName
Set olContact = olApp.CreateItem(olContactItem)
Set olNS = olApp.GetNamespace("MAPI")
Set olFolder = olNS.GetDefaultFolder(olFolderContacts)
blnContinue = True
If Not IsNull(strFirstName) And Not IsNull(strLastName) Then
Set olContact = olFolder.Items.Find("[lastname] = " & strLastName)
If Not TypeName(olContact) = "Nothing" Then 'Match found
varReturnVal = MsgBox("A record with the same first and last
names already exists in Outlook. Continue?", vbOKCancel, "Duplicate
name")
If varReturnVal = vbCancel Then
blnContinue = False
End If
End If
End If
.
.
.
.