Location document

i have this code and it works, but i now i need to check if there is a location document with the same name or same mailbox as a location doc. Can someone help me with this?

Sub Click(Source As Button)

'CreateLocation “name1”, “server1”, “mail/mailbox1”, “c:\notes\data\userid1”

'CreateLocation “name2”, servers2", "mail/mailbox2, “c:\notes\data\userid2”

'CreateLocation “name3”, “server3”, “mail/mailbox9”, “c:\notes\data\userid3”

End Sub

Sub CreateLocation(locName As String, serverName As String, mailboxName As String, userId As String)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Set db = session.GetDatabase(“”, “names.nsf”)

Set doc = db.CreateDocument

doc.Form = “Location”

doc.Type = “Location”

doc.LocationType = “0”

doc.Name = locName

doc.MailServer = servername

doc.DefaultPassthruServer = " "

doc.CatalogServer = servername

doc.EnabledPorts = “TCPIP”

doc.MailFile = mailboxname

Doc.Domain = “domain”

doc.IMailAddress = " "

Doc.Webretriever = “2”

doc.UserID = userid

doc.USEOSTz = “1”

Call doc.ComputeWithForm( False, True )

doc.save True, True

'Msgbox “Location document(s) created!”

Subject: location document

Something like this will check for a location name that already exists:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim vw As NotesView

Dim dc As NotesViewEntryCollection

Set db = session.GetDatabase("", "names.nsf")

Set vw = db.GetView("Locations")

Set dc = vw.GetAllEntriesByKey(locName, True)

If dc.Count > 0 Then

	Exit Sub

End If

Set doc = db.CreateDocument

doc.Form = "Location"

doc.Type = "Location"

doc.LocationType = "0"

doc.Name = locName

doc.MailServer = servername

doc.DefaultPassthruServer = " "

doc.CatalogServer = servername

doc.EnabledPorts = "TCPIP"

doc.MailFile = mailboxname

Doc.Domain = "domain"

doc.IMailAddress = " "

Doc.Webretriever = "2"

doc.UserID = userid

doc.USEOSTz = "1"

Call doc.ComputeWithForm( False, True )

doc.save True, True

'Msgbox “Location document(s) created!”

Subject: RE: location document

hey Paul,

Big thank for your help, it worked like a charm…

Ron