Solved

Validatation

Posted on 2006-12-01
8
189 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
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 

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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 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