?
Solved

Validatation

Posted on 2006-12-01
8
Medium Priority
?
194 Views
Last Modified: 2013-12-18
Experts,
       I have 20 fields (desc1, desc2, desc3........) that is hidden depending upon the user's input. Sample, if user inputs 5 then 5 desc1... fields will be displayed. Now, the problem I need to validate if all 5 desc and it must NOT be empty (the user can also pick 10 or more).
       Is there a a more efficient way to validate (maybe loop)?
Thank you!  
 
0
Comment
Question by:cyle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 18056609
Validation can be done in a loo if he field names are similarly names, which is always a good idea in your kind of scenario.

It can be done in the query save portion.

I'll find some code.

I hope this helps !
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 18056669
If felds are s1, s2 s..



In query save
' untested
Dim Nitem As NotesItem, Tstr2 As String
Dim DBE As NotesDocument
Dim ivalue  As Variant , v2 As integer
      Dim Dstr As String, Dstr1 As String, sdt as string
      
      Set dbe=source.Document      
      
      If source.IsNewDoc Then ' do any validation if needed
            
     for v2 = 1 to n  ' n is chosen and saved some where

        Sdt= "S" & v2  'set saved audit field
       Set Nitem = dbe.GetFirstItem( Sdt )
        ' validate here
        If not valid ' do your validation
           Continue = False
        end if
        ' set continue to false if not valid
     next
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 18056682
you could also use  source.fieldGetText(SDT)  instead of the GetItem

I hope this helps !

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:cyle
ID: 18056706
Thank you, let me try it!
0
 
LVL 18

Expert Comment

by:marilyng
ID: 18059964
Hi cyle,
I usually add a multivalue field to the bottom of the form that lists or computes the fields that need to be validated.  So, in a simple form where I have three fields:  UserName, Address, Phone,  the multivalue field's (labeled validate) calculated value = "UserName":"Address":"Phone".

Then I can use the same validation script in the query close event in just about any form:

Sub Querysave(Source As Notesuidocument, Continue As Variant)
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Set db = session.currentDatabase
    Dim doc As NotesDocument
    Set doc = source.document
    continue = True
   
    If source.EditMode Then
        source.refresh
    End If
   
    Dim FieldList As Variant
   
    If Len(doc.Validate(0)) > 0 Then
        fieldList = doc.Validate
       
        Forall f In FieldList
            If Len(doc.GetItemValue(f)(0))<1 Then
                Msgbox "Sorry, the " + f + " field may not be blank",,"Validation Error!"
                continue = False
                source.GotoField(f)
                Exit Sub
            End If
        End Forall
    End If
   
End Sub

--------------------------
Based on your problem, you can easily concatenate the formula on your form to include the selected fields:

F1:= @If(Select_1 !="";"UserName";"");
F2:= @If(Select_2 !="";"Address";"");
F3:= @If(Select_3 !="";"Phone";"");

@Trim(F1:F2:F3)


Regards!
0
 
LVL 3

Accepted Solution

by:
Joep8020 earned 1500 total points
ID: 18118799
Easiest way is good all @Formula language:

Let's assume the input field is called InputField and contains a numeric value; then use this formula in the input validation of the input field:
tNr:=@If(@Text(InputField)="";@Return("");InputField);
tList:=@Subset(desc1:desc2: desc3: desc4: desc5: desc6: desc7: desc8: desc9: desc10: desc11: desc12: desc13: desc14: desc15: desc16: desc17: desc18: desc19: desc20;tNr);
@If(@Elements(@Trim(tList))<tNr;@Failure("You need to give at " + @Text(tNR) + " descriptions";@Success);

Hope this will work for you...

0
 
LVL 18

Expert Comment

by:marilyng
ID: 18119676
Close!  But, missing a beat.   You would have to define the sets that are visible.

So, if when the user selects "1", desc1,desc2,desc3,desc4 are visible, then you need to validate those four fields.
If when the user selects "2", desc5, desc6, desc7,desc8 are visible, then validate those four fields.

Set1:=desc1:desc2: desc3: desc4;
Set2:=desc5: desc6: desc7: desc8;
Set3:=desc9: desc10: desc11: desc12;
Set4:=desc13: desc14: desc15: desc16;
Set5:=desc17: desc18: desc19: desc20;
REM "User Input is a List that returns a number This Value|1";
UserSelection:=@TextToNumber(UserInput);

@if(UserInput="";@Success;
   @If(
         @Elements(@Trim(@Select(UserSelection;Set1;Set2;Set3;Set4;Set5)))!=
         @Elements(@Select(UserSelection;Set1;Set2;Set3;Set4;Set5));
         @Failure("Sorry, Description fields may not be empty");
@Success))
0
 
LVL 18

Expert Comment

by:marilyng
ID: 18119681
Oops, I put a "Validate" field, text, editable, hidden at the bottom of the form, and put the formula in the validation event.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question