Solved

Validatation

Posted on 2006-12-01
8
186 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
8 Comments
 
LVL 63

Expert Comment

by:SysExpert
Comment Utility
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
Comment Utility
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
Comment Utility
you could also use  source.fieldGetText(SDT)  instead of the GetItem

I hope this helps !

0
 

Author Comment

by:cyle
Comment Utility
Thank you, let me try it!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 18

Expert Comment

by:marilyng
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now