I need to get the script that will close a form if there is a duplicate entry for a field. The code now is either not working or is prompting the user if they want to save. If a form has already been entered it should alert that them that this office has already completed the form and close the window without saving. Here is the current code.
Sub Exiting(Source As Field)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim agynum As String
Set uidoc = workspace.CurrentDocument
Set db = session.CurrentDatabase
Set ndoc = uidoc.Document
Set view = db.GetView("(completed)")
' Call uidoc.Save
agynum = uidoc.FieldGetText( "office_number")
key = agynum
Set ndoc = view.GetDocumentbyKey(key)
If ndoc Is Nothing Then
Msgbox "Thank you, but a survey has already been completed for your agency. "