How to mimic @Return in lotusscript?

I am putting code in a querysave event that will not let a user save a document if a duplicate exists. I am trying to do field validation also by saying if a field isn’t 10 digits long then pop up a msgbox and let the user edit the field. Below is the code that does the validation but it closes the form afterwards. How can I get the form to stay open for the user?

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim npi As String

Dim ssn As String



Set db = session.CurrentDatabase

Set uidoc = ws.CurrentDocument



Set CheckSaveView = db.GetView("(CheckSave)")

SSN = uidoc.FieldGetText("SSN")

NPI = uidoc.FieldGetText("NPI")

Set doc = CheckSaveView.GetDocumentByKey(SSN)



If Len(NPI) =10 Then

	'do nothing 

Else

	Msgbox "The NPI Number must be ten digits, please correct"

Continue = False

End If



If uidoc.IsNewDoc Then

	If Not (doc Is Nothing) Then		

	'Messagebox  "There is a document already, do NOT save"

		Call uidoc.FieldSetText("SaveOptions", "0")

	Else

		

	End If

End If

End Sub

Subject: How to mimic @Return in lotusscript?

Two things…

First, I would:

SSN = FullTrim(uidoc.FieldGetText(“SSN”)) 'Use Trim if on pre R6 platform

NPI = FullTrim(uidoc.FieldGetText(“NPI”))

and second,

this Call uidoc.FieldSetText(“SaveOptions”, “0”) is redundant and probably won’t work (you can’t FieldSetText on a nondisplayed field) so just use the Continue =False again, that should stop the save.

Subject: How to mimic @Return in lotusscript?

Mike,

I think this is what you’re asking for …

Messagebox “The NPI Number must be ten digits, please correct”

Continue = False

exit sub

regards,

raphael

Subject: RE: How to mimic @Return in lotusscript?

Thanks but I have tried that, it just exits the sub, saves it and closes the document.

Subject: RE: How to mimic @Return in lotusscript?

Mike,

Use your debugger to see where your code goes. If it’s saving and closing the document, then it’s not doing so in that part of the code.

regards,

raphael

Subject: How to mimic @Return in lotusscript?

give this a go:

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim session As New NotesSession

Dim doc As NotesDocument

Dim npi As String

Dim ssn As String



Set db = session.CurrentDatabase

Set uidoc = ws.CurrentDocument



Set CheckSaveView = db.GetView("(CheckSave)")

SSN = Source.FieldGetText("SSN")

NPI = Source.FieldGetText("NPI")

Set doc = CheckSaveView.GetDocumentByKey(SSN)



If Len(NPI) =10 Then

'do nothing

Else

	Msgbox "The NPI Number must be ten digits, please correct"

	Call Source.GotoField("NPI")

	Continue = False

	Goto fixnpi

End If



If Source.IsNewDoc Then

	If Not (doc Is Nothing) Then 

'Messagebox “There is a document already, do NOT save”

		Call Source.FieldSetText("SaveOptions", "0")

	Else

		

	End If

End If

fixnpi:

End Sub