This is an addition of a previous post that I submitted. In the earlier post, I was receiving errors when I tried to save the form. I moved the input validation formula from a field on the form into the QuerySave event of the form (I added the code below). Now, I do not receive any errors but the validation formula is not validating which means that it allows me to save duplicate locations. Any anyone shed any light on this? Thanks!
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim docs As NotesDocumentCollection
Dim curDoc As NotesDocument
Dim doc As NotesDocument
Dim searchFormula As String
Set db = session.CurrentDatabase
Set source = workspace.CurrentDocument
Set curDoc = source.Document
searchFormula = { Form = “Location Lookup” & Location = “} + curDoc.Location(0) + {” & Region = “} + curDoc.Region(0) + {” & Division = “} + curDoc.Division(0) + {”}
Set docs = db.Search(searchFormula, Nothing, 0)
Set doc = docs.GetFirstDocument
If docs.Count > 1Then
If (doc.UniversalID = source.Document.UniversalID) Then
Msgbox "A saved location document already exists with this name " + doc.Location(0), 0 + 48, “Duplicate Location”
Continue = False
End If
End If
source.document.Date_Edited = Now
End Sub