I want to apply a check to stop duplicate entery.for example if a person enters his name twice,a message"Already Existing"should pop up.
Subject: To stop duclicate entry
I don´t understod very well, I think that you need to validate user doesn´t duplicate in a collection, maybe. First I create a view sort by field validated (view = “Gerencias” field = “geDescrip”). Then on Querysave event:
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim Sesion As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim campo As String
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Set uidoc = workspace.CurrentDocument
flag=False
campo1= uidoc.FieldGetText( "geDescrip" ) 'Field validated from Form
If campo1 <> "" Then
Set db= Sesion.currentdatabase
Set view = db.GetView( "Gerencias" ) 'View sorted by geDescrip field
Set doc = view.GetDocumentByKey( campo1 )
Dim nuevo As String
nuevo = uidoc.FieldGetText( "NuevoDoc" ) 'Buevo doc field contains @if(@isnewdoc;"0";"1"))
If Not (Doc Is Nothing) And nuevo="0" Then
'If found
Messagebox "La Gerencia ya existe.",0+16 , "Error"
Call uidoc.FieldSetText ( "geDescrip", "" )
Call uidoc.FieldSetText ( "SaveOptions", "0" ) 'Field SaveOptions is a computed hide text field
End If
Else
Messagebox "Error, El campo Descripción. es obligatorio",0+16 , "Atención"
Call uidoc.FieldSetText ( "SaveOptions", "0" )
End If
If flag Then
Messagebox "El registro ha sido guardado",0+64 , "Exito"
Else
Messagebox "El documento presenta errores, no será salvado",0+16 , "Error"
End If
End Sub
I hope it help you.