Anthony -
Try using a temporary "display" document to perform your validation against instead. For example:
- sub main()
on error goto errorHandler
dim wrkspc as NotesUIWorkspace
dim uiDoc as NotesUIDocument
dim thisDoc as NotesDocument
dim dispDoc as NotesDocument
dim bShowDbox as Boolean
dim bIsDocValid as Boolean
dim sMsg as String
dim vTmp as Variant
dim reqFldsLst List as String
set wrkspc = new NotesUIWorkspace
set uiDoc = wrkspc.CurrentDocument
set thisDoc = uiDoc.Document
set dispDoc = new NotesDocument(thisDoc.ParentDatabase)
reqFldsLst("Label for required field #1") = "RequiredFieldName_01"
reqFldsLst("Label for required field #2") = "RequiredFieldName_02"
reqFldsLst("Label for required field #3") = "RequiredFieldName_03"
uiDoc.AutoReload = false
call dispDoc.ReplaceItemValue("FieldToLoad", thisDoc.GetItemValue("FieldToLoad"))
'// insert code to load the display document with any additional values you may need
bShowDbox = true
while bShowDbox
if not(wrkspc.DialogBox("(SomeSubFormName)", true, true, false, true, false, false, "Dialog title . . .", dispDoc)) then
Print "Action cancelled . . ."
Goto subExit '//if user cancels the dialog, exit
else
sMsg$ = "Please provide a value for the following fields:" & Chr(13)
bIsDocValid = true
forall fld In reqFldsLst
vTmp = dispDoc.GetItemValue(fld)
if trim$(vTmp(0)) = "" then
bIsDocValid = false
sMsg$ = sMsg$ & listtag(fld) & Chr(13)
end if
end forall
if bIsDocValid then
bShowDbox = false
else
msgbox sMsg$, , "Required fields . . ."
end if
end if
wend
'// update the document with new values provided by user in the dialogbox
forall fld In reqFldsLst
call thisDoc.ReplaceItemValue(fld, dispDoc.GetItemValue(fld))
end forall
call uiDoc.Reload()
subExit:
if not(uiDoc is nothing) then
uiDoc.AutoReload = true
end if
exit sub
errorHandler:
Msgbox "Error " & Err & ": " & Error$ & " encountered at line " & Erl & " of " & Getthreadinfo(1) & ".", ,_
"Error encountered . . ."
print "Error " & Err & ": " & Error$ & " encountered at line " & Erl & " of " & Getthreadinfo(1) & " . . ."
resume subExit
end sub
This allows you to perform the validation from within the calling procedure while giving the user as many chances as s/he wants to try to get it right.
dgg