I am calling this agent in the Queryopen event of the form.Dim session As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim doc1 As NotesDocument
Set session = New NotesSession
Set db=session.CurrentDatabase
Set doc=session.DocumentContext
Set view =db.GetView("ALL DOCUMENTS")
Set doc1=view.getfirstdocument
While Not doc1 Is Nothing
a=doc1.uname(0)
b=doc.uname(0)
If a=b Then
doc.msg= "You have already submitted"
Else
doc.msg="Your form is Saved"
Call doc.Save(True,True)
End If
Set doc1=view.getnextdocument(doc1)
Wend
But data is not getting saved.