'ValidateForm: ' create, written, and debuged, by Ian Irving http://www.FalsePositves.com 2006 'http://www.falsepositives.com/index.php/2006/05/02/sntt-lotusscript-required-field-validation-without-pain-revisted/ Option Public Option Explicit %REM Text Edited hidden field, allowing multi values called "ListOfRequiredFields" with defaultValue = "UseName|Name": "CmpName|Company Name": @if(Status="Pending";"Value|Total Budget Amount ($)"; “”): @if (country="USA"; "Province|State";"Province|Province") each element on this list is is of the structure : FieldName|FeildLabel where FieldName is the actual name of the field on the form, and FieldLabel how the feild is refreed to by the user user use this in your Form's Query Save " Sub Querysave(Source As Notesuidocument, Continue As Variant) Dim doc As NotesDocument Set doc = Source.Document dim FormLabel as String FormLabel = "Admin Profile" If ValidateForm ( Doc, FormLabel, "ListOfRequiredFields" )Then Continue = True Else Continue = False Exit Sub End If End Sub %END REM %INCLUDE "LSCONST.LSS" Function ValidateForm (Doc As NotesDocument, FormName As String, FNforLoR As String ) As Integer ' pass the Notes Doc to Validated; the name you wish to refree when talking about the form, The Field Name on the document with the list of required field and Field Label On Error Goto processError Const NoCaseNoPitch = 5 Dim errPre As String Dim errMsg As String Dim msgTitle As String Dim LoRitem As NotesItem ' List of Required Fields item Dim pos As Integer Dim FieldName As String Dim FieldLabel As String Dim CRLF As String Set LoRitem = Doc.GetFirstItem (FNforLoR) If LoRitem Is Nothing Then ValidateForm = True Exit Function Elseif LoRitem.text = "" Then ' Nothing To test ValidateForm = True Exit Function End If CRLF= Chr(13)' & Chr$(10) msgTitle = "Validation Error saving " + FormName errPre ="The following field(s) are blank , or incorrect, and must be inputted before saving:" & CRLF & CRLF ErrMsg = "" Forall V In LoRitem.Values pos = Instr (1, V, "|" ,NoCaseNoPitch ) FieldName = Trim( Left( V, pos - 1)) FieldLabel = Trim(Mid(V, pos +1) ) If isVaildateFieldEmpty ( Doc, FieldName) Then ErrMsg = errMsg & CRLF & FieldLabel End If End Forall If Not errMsg = "" Then Messagebox errPre & errMsg, MB_OK+MB_ICONSTOP, msgTitle ValidateForm = False Else ValidateForm = True End If Exit Function processError: Messagebox "System Error " & Err() & ": " & Error$ & ", line: " & Erl ValidateForm = False End Function Function isVaildateFieldEmpty (Doc As NotesDocument , FieldName As String ) As Integer ' pass in the document to be validated, and the FieldName If Not doc.hasitem(FieldName) Then ' if the field is not on the document report that as being empty isVaildateFieldEmpty = True Exit Function End If If doc.GetFirstItem (FieldName).text = "" Then isVaildateFieldEmpty = True Else isVaildateFieldEmpty = False End If End Function